I want that when a player presses a button, his character become ragdoll, but he can move while ragdoll

  1. **What do you want to achieve?**I want that when a player presses a button, his character become ragdoll, but he can move while ragdoll

  2. What is the issue? I can’t move while ragdoll

  3. What solutions have you tried so far? Ragdoll module for all character - #22 by Ofc_Infinitybad The problem is that i cannot move when i’m ragdoll

So basically this is my client script

script.Parent.MouseButton1Click:Connect(function()
	
	local plr = game.Players.LocalPlayer
	plr.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)

	game.ReplicatedStorage.Ragdoll:FireServer(plr)
	
end)

and this is the server script

game.ReplicatedStorage.Ragdoll.OnServerEvent:Connect(function(plr)

local RagdollModule = require(game.ReplicatedStorage.RagdollModule)
	RagdollModule:RigPlayer(plr.Character)
	end)

And this is the module script

local mod = {}

function mod:RigPlayer(Character : Model)
	local hum : Humanoid? = Character:WaitForChild("Humanoid")
	local hrp : BasePart? = Character:WaitForChild("HumanoidRootPart")
	local db = false

	assert(hum,Character.Name.." isnt a humanoid")

	hum.BreakJointsOnDeath = false
	local WeldConstranint = Instance.new("WeldConstraint",hrp)
	for _,v in pairs(Character:GetDescendants()) do
		if v:IsA("Motor6D") then
			local BallSocket = Instance.new("BallSocketConstraint",v.Part0)
			BallSocket.Name = "BC"
			if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
				v.Part1.CanCollide = false
				v.Part0.CanCollide = false
			end

			local att1 = Instance.new("Attachment",v.Part0) att1.Name = "AttRag"
			local att2 = Instance.new("Attachment",v.Part1) att1.Name = "AttRag"
			att2.Position = v.C1.Position
			att1.WorldPosition= att2.WorldPosition

			BallSocket.LimitsEnabled = true
			BallSocket.TwistLimitsEnabled = true

			BallSocket.Attachment0 = att1
			BallSocket.Attachment1 = att2

			if v.Part0 == Character.PrimaryPart and v.Part1 ~= Character.PrimaryPart then
				WeldConstranint.Part0 = Character.PrimaryPart
				WeldConstranint.Part1 = v.Part1
				WeldConstranint.Enabled = false
			end
		end
	end
	hum:GetPropertyChangedSignal("Health"):Connect(function()
		if hum.Health <= 0 and db == false then
			db = true
			for _, v in ipairs(Character:GetDescendants()) do
				if v:IsA("Motor6D") then
					if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
						v.Part1.CanCollide = true
						v:Destroy()
					else
						WeldConstranint.Enabled = true
						Character.PrimaryPart.CanCollide = false
					end
				end
			end
		end
	end)
	hum.StateChanged:Connect(function(_,State)
		if State == Enum.HumanoidStateType.Physics then
			for _, v in ipairs(Character:GetDescendants()) do
				if v:IsA("Motor6D") then
					if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
						v.Part1.CanCollide = true
						v.Enabled = false
					else
						WeldConstranint.Enabled = true
						Character.PrimaryPart.CanCollide = false
					end
				end
			end
		elseif State == Enum.HumanoidStateType.GettingUp then
			for _, v in ipairs(Character:GetDescendants()) do
				if v:IsA("Motor6D") then
					if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
						v.Part1.CanCollide = false
						v.Enabled = true
					else
						WeldConstranint.Enabled = false
						Character.PrimaryPart.CanCollide = true
					end
				end
			end
		end
	end)
end

return mod

I also tried to make a script, but it is rly bugged (the character literally fly)

game.ReplicatedStorage.Ragdoll.OnServerEvent:Connect(function(plr)
	
	
	local character = plr.Character
	local humanoid = character:FindFirstChild("Humanoid")
	
	for _, joint in pairs(character:GetDescendants()) do
		if joint:isA("Motor6D") and joint.Name ~= "Neck" then
			local socket = Instance.new("BallSocketConstraint", joint.Parent)
			local a0 = Instance.new("Attachment")
			local a1 = Instance.new("Attachment")

			socket.Attachment0 = a0
		socket.Attachment1 = a1

			a0.Parent = joint.Part0
			a1.Parent = joint.Part1

			a0.CFrame = joint.C0
			a1.CFrame = joint.C1

			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true

			joint:Destroy()
		end
	end
	end)

Try changing physics in module to something like ragdoll and then call ragdoll on the humanoid state instead of physics since physics just turns off whole character controller.
Edit: want to say also that you might want to change getting up state as well since roblox might call it automatically. Im currently working on a simple update to the module so that the connections arent even in the module and will just ragdoll character if the module function is called so the module is more versatile.

1 Like

Ty for the answer.
I tried to do a script like this which doesn’t include the change state of humanoid. I don’t really understand what do you mean by “changing physics in module to something like ragdoll” and i don’t really knwo how to do it. I mean the script i’ve written is really bugged. If i jump multiple times i literally fly… I’m not very knowledgeable about these things… Can you please explain what do you mean?

game.ReplicatedStorage.Ragdoll.OnServerEvent:Connect(function(plr)
	
	
	local character = plr.Character
	local humanoid = character:FindFirstChild("Humanoid")
	
	for _, joint in pairs(character:GetDescendants()) do
		if joint:isA("Motor6D") and joint.Name ~= "Neck" then
			local socket = Instance.new("BallSocketConstraint", joint.Parent)
			local a0 = Instance.new("Attachment")
			local a1 = Instance.new("Attachment")

			socket.Attachment0 = a0
		socket.Attachment1 = a1

			a0.Parent = joint.Part0
			a1.Parent = joint.Part1

			a0.CFrame = joint.C0
			a1.CFrame = joint.C1

			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true

			joint:Destroy()
		end
	end
	end)

I tried to make another script, but when i become ragdoll i literally fly. Can someone help me fixing the problem?

This is the script

game.ReplicatedStorage.Ragdoll.OnServerEvent:Connect(function(plr)
	local character = plr.Character
	local humanoid = character:WaitForChild("Humanoid")

	local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
	humanoidRootPart.CanCollide = false

	for _, joint in pairs(character:GetDescendants()) do
		if joint:IsA("Motor6D") and joint.Name ~= "Neck" then
			local socket = Instance.new("BallSocketConstraint", joint.Parent)
			local attachment0 = Instance.new("Attachment")
			local attachment1 = Instance.new("Attachment")

			socket.Attachment0 = attachment0
			socket.Attachment1 = attachment1

			attachment0.Parent = joint.Part0
			attachment1.Parent = joint.Part1

			attachment0.CFrame = joint.C0
			attachment1.CFrame = joint.C1

			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true
		--	socket.Restitution = 1
			--socket.MaxFrictionTorque = Vector3.new(0,0,0)
			

			joint:Destroy()
		end
	end
end)

This is what happen

(there is shift lock because i made a capture of the screen, but i didn’t have shift lock)
@Ofc_Infinitybad Ofc_Infinitybad

Are there any scripts that has the line “ :GetControls() “ ? It could be remove the players controls when ragdolling or when pressing that key.

1 Like

Ty for the answer

No, there aren’t scripts with the line: GetControls() and i also awnt that the player can control his character while ragdoll

a type of ragdoll like this is also ok

(In this game while ragdoll you can also lose legs and other body parts etc)

For the moving bit, you can give yourself velocity when you get certain inputs.

1 Like