Temporary Ragdoll

I was trying to make a temporary ragdoll that disable Motor6D when your humanoid health is 1 but i can’t still figure it out how to function it

Code:
local function TemporaryRagdoll(Character)
	for i, v in pairs(Character:GetDescendants()) do
		if v:IsA("Motor6D") then
			v.Enabled = false
		end
	end
end

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if Character.Humanoid.Health > 1 then
			TemporaryRagdoll()
		end
	end)
end)

You’re only running the function when the character is added, in which case the player’s health will be above 1 health by default. You need to connect your “TemporaryRagdoll” function to the Humanoid’s HealthChanged event for it to check the player’s health any time it changes.

1 Like

You can use HealthChanged for this type scenario.
You can try this script if it’ll work for you.

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
		Humanoid.HealthChanged:Connect(function(health)
			if Character.Humanoid.Health > 1 then
				TemporaryRagdoll()
			end
		end)
	end)
end)
1 Like

You have a ‘Health’ parameter so use that instead.
if Health > 1 then

1 Like