Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ragdoll system not setting player to physical state?

Asked by 3 years ago

Hey there! Writing my R6 ragdoll script currently but when setting the mode to physical or trying to change it the state won't change at all. Any ideas as to what I do or what I did wrong?

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local DeadPos = CFrame.new(0, 0, 0)

        local Humanoid = Character:WaitForChild("Humanoid")

        Humanoid.BreakJointsOnDeath = false
        Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)

        Humanoid.Jumping:Connect(function()

            DeadPos = Character.HumanoidRootPart.CFrame 

            Humanoid:ChangeState(Enum.HumanoidStateType.Physics)

            for _, Limb in pairs(Character:GetDescendants()) do

                if Limb:IsA("Motor6D") then
                    local Attachment0, Attachment1 = Instance.new("Attachment"), Instance.new("Attachment")

                    Attachment0.CFrame = Limb.C0
                    Attachment1.CFrame = Limb.C1

                    Attachment0.Parent = Limb.Part0
                    Attachment1.Parent = Limb.Part1

                    local Joint = Instance.new("BallSocketConstraint")

                    Joint.Attachment0 = Attachment0
                    Joint.Attachment1 = Attachment1

                    Joint.Parent = Limb.Part0

                    Limb:Destroy()
                    end
                end
        end)
    end)
end)

Answer this question