#ragdoll problem

1 messages · Page 1 of 1 (latest)

lament patio
#
function addRag(char)
    for i, v in char:GetDescendants()  do
        if v:IsA("Motor6D") then
            local socket = Instance.new("BallSocketConstraint")
            socket.Parent = v.Parent
            
            local at1 = Instance.new("Attachment")
            local at2 = Instance.new("Attachment")
            at1.Name = "at1"
            at2.Name = "at2"
            at1.Parent = v.Part0
            at2.Parent = v.Part1
            
            char.Head.CanCollide = true
            char.LeftHand.CanCollide = true
            char.RightHand.CanCollide = true
            char.RightFoot.CanCollide = true
            char.LeftFoot.CanCollide = true
            char.UpperTorso.CanCollide = true
            char.LowerTorso.CanCollide = true
            char.LeftUpperLeg.CanCollide = true
            char.RightUpperLeg.CanCollide = true
            char.LeftUpperArm.CanCollide = true
            char.RightUpperArm.CanCollide = true
            char.LeftLowerLeg.CanCollide = true
            char.RightLowerLeg.CanCollide = true
            char.LeftLowerArm.CanCollide = true
            char.HumanoidRootPart.CanCollide = true
            
            at1.CFrame = v.C0
            at2.CFrame = v.C1
            socket.Attachment0 = at1
            socket.Attachment1 = at2
            socket.LimitsEnabled = true
            socket.TwistLimitsEnabled = true
            v.Enabled = false
            
        end
        
    end
end


task.wait(3)

addRag(game.Workspace.cooltayfa)


this is the whole script but can someone tell me why do i suddenly start flying upwards i dont get it

lament patio
#

why the melon

unreal umbra
#

just use one from toolbox

heavy helm
#

probably self collisions

lament patio
lament patio
halcyon lily
#

you have to set the humanoidstatetype of the character to physics

#

🥀

lament patio
#

i think i found it

#

humanoid:ChangeState(Enum.HumanoidStateType.Physics)

#

it should be this

#

butim still flying

#

roblox might be setting it back to default

halcyon lily
#

is the character youre ragdolling an npc perchance?

lament patio
#

myself

halcyon lily
#

it has to be ran on the client btw

lament patio
#

found the fix for it

halcyon lily
#

no it has to be called on the client

#

for your own character it probably does

#

but if youre gonna do this for npcs

#

then you have to call changestate from the client and ONLY from the client

#

or else theyd float up while dangling

#

make a Script instance and make it have the 'Client' RunContext property (will be running from the client while having different logic to be used outside of a character or player)
and put that Script inside of ReplicatedFirst or another container

#

just have a tag like ragdolled when ragdolling and remove that tag when theyre unragdolling

#

and have a script that does something similarly to this or just copy my code i dont really care or mind

#
local CollectionService = game:GetService("CollectionService")

CollectionService:GetInstanceAddedSignal("Ragdoll"):Connect(function(Character)
    if not Character:IsA("Model") then return end
    
    Character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
    Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
end)

CollectionService:GetInstanceRemovedSignal("Ragdoll"):Connect(function(Character)
    if not Character:IsA("Model") then return end
    
    local Humanoid = Character:FindFirstChildOfClass("Humanoid")
    if not Humanoid or Humanoid:GetState() == Enum.HumanoidStateType.Dead then return end
    
    for _, Part: BasePart in ipairs(Character:GetDescendants()) do
        if not Part:IsA("BasePart") then continue end
        
        Part.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
        Part.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
    end
    Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
    Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
end)
#

and make sure it's a SCRIPT instance that has the RunContext Property as 'Client' and NOT a LocalScript.

#

only reason im telling you this is because youre definitely gonna have problems for npcs that arent network owned

#

and the reason why I never told you the solution was cause I felt lazy

#

(mbmb)

lament patio
#

i've tested

#

for both server and client

#

it works just fine

#

works for npc's also

#

to fix the dangling

#

all i had to do was

#

set the humanoid stateevaluate thingy to false

halcyon lily
#

so it should be client* by default

#

if your player doesnt render the npcs ragdoll physics they start dangling

lament patio
#

if thats what you mean

#

yeah it is networkowned to the player7

#

but its server script

halcyon lily
#

thats why exploiters can do some stuff like making objects float/move when an unanchored part is network owned to them

#

its some weird roblox spaghetti

#

so ragdolls get weird