Help With Ragdoll Script

I made this lil ragdoll script but sometimes the player will stay standing up after dying, i want to know how i could make it push the player backwards a little so they will fall over.

–The Script

game.Players.PlayerAdded:Connect(function (player)
	
	player.CharacterAdded:Connect(function (char)
		
		local hum = char:FindFirstChild("Humanoid")
		local HumRoot = char:FindFirstChild("HumanoidRootPart")
		hum.BreakJointsOnDeath = false
		
		
		hum.Died:Connect(function ()
			for _, descendant in pairs(char:GetDescendants()) do
				if descendant:isA("Motor6D") then
					local socket = Instance.new("BallSocketConstraint")
					local a1 = Instance.new("Attachment")
					local a2 = Instance.new("Attachment")
					a1.Parent = descendant.Part0
					a2.Parent = descendant.Part1
					socket.Parent = descendant.Parent
					socket.Attachment0 = a1
					socket.Attachment1 = a2
					a1.CFrame = descendant.C0
					a2.CFrame = descendant.C1
					socket.LimitsEnabled = true
					socket.TwistLimitsEnabled = true
					descendant:Destroy()
				end
				
			end
		end)
		
		
	end)
end)

You could ApplyImpulse() a force on the humanoid root part, which would push it in the direction and with the force you added. For example HumRoot:ApplyImpulse(HumRoot.CFrame:ToWorldSpace(Vector3.new(0, 0, 250))) would push the player backwards with a force of 250. You would put this in the Died connection after the for loop.

1 Like

it gave me this error invalid argument #2 (CFrame expected, got Vector3) - Server - PlayerRagdoll:26

Oops, it should’ve been HumRoot:ApplyImpulse(HumRoot.CFrame:VectorToWorldSpace(Vector3.new(0, 0, 250)))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.