Player's character is controllable and stands upright whilst ragdolling

I have a ragdoll script for my game that toggles a BoolValue when it should ragdoll. Currently, the player is still able to control their character while they are ragdolling. How could I fix this?

Example video:

Code:

local humanoid = script.Parent:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false

local character = script.Parent
local torso = character:WaitForChild("Torso")
local hrp = character:WaitForChild("Torso")

local animatescript = character:WaitForChild("Animate")

local RagdollStorage = Instance.new("Folder")
RagdollStorage.Parent = humanoid.Parent
RagdollStorage.Name = (humanoid.Parent.Name .. "Ragdoll")

--------------------------------------------------

script.Ragdolling.Changed:Connect(function(newvalue)
	if script.Ragdolling.Value == true then
		print("Starting " .. character.Name .. "'s ragdoll")
		animatescript.Disabled = true
		script.Parent.Dash.SlideDisabled.Value = true
		for index,joint in pairs(script.Parent:GetDescendants()) do
			if joint:IsA("Motor6D") then
				local socket = Instance.new("BallSocketConstraint")
				local a1 = Instance.new("Attachment")
				local a2 = Instance.new("Attachment")
				a1.Parent = joint.Part0
				a2.Parent = joint.Part1
				socket.Parent = joint.Parent
				socket.Attachment0 = a1
				socket.Attachment1 = a2
				a1.CFrame = joint.C0
				a2.CFrame = joint.C1
				socket.LimitsEnabled = true
				socket.TwistLimitsEnabled = true
				joint.Enabled = false
				joint.Parent = RagdollStorage
			end
		end
	elseif script.Ragdolling.Value == false then
		animatescript.Disabled = false
		script.Parent.Dash.SlideDisabled.Value = false
		print("Stopping " .. character.Name .. "'s ragdoll")
		for index,joint in pairs(script.Parent:GetDescendants()) do
			if joint:IsA("BallSocketConstraint") then
				joint:Destroy()
			end
		end
		for i, m6d in pairs(RagdollStorage:GetDescendants()) do
			if m6d:IsA("Motor6D") then
				if m6d.Name == 'RootJoint' then
					m6d.Parent = hrp
					m6d.Enabled = true
				else
					m6d.Parent = humanoid.Parent.Torso
					m6d.Enabled = true
				end
			end
		end
	end
end)

--------------------------------------------------

humanoid.Changed:Connect(function(whatchanged)
	if whatchanged == 'Health' then
		if humanoid.Health < 10 then
			script.Ragdolling.Value = true
		else
			script.Ragdolling.Value = false
		end
	end
end)

Any help would be much appreciated!

1 Like

I believe the easiest way to disable the movement is to set the JumpPower and WalkSpeed to 0

Doing that sitll causes the player to stand half-upright, without actually falling.

Try looking at HumanoidStateType. Changing the state to Physics may stop it from standing up, though I’m not completely sure.

1 Like

Set HumanoidStateType to Ragdoll. This will make player not able to move.

This still has the same results before, setting the state type to physics still lets the player move. Same thing happens with @SkiuulLPcz’s reply.

Are you changing the state in a LocalScript or a Script? It seems like this kind of thing should be done Locally

I tried it with both a server script and a local script and they both have the same results.

do it locally. You can try disabling all states except radgoll by :SetStateEnabled()
Other than that you could set Velocity to 0,0,0…

Setting all the states to disabled still doesn’t affect anything.

I found something! This was already brought up in the past here

Disabling the controls doesn’t matter, I feel like your misunderstanding my problem. Even if the player is unable to move via walkspeed or disabling controls, their character will still stand somewhat upright instead of falling to the floor.

I see… Well thats hipheight. Change hipheight to 0

Changing HipHeight doesn’t make any difference.