Looping Humanoid:ChangeState to Ragdoll cause death to fire multiple times

Used the following to catch when the player humanoid died.

System Information:
Windows 11 Pro 24H2

2 Likes

Every time you set it to ragdoll doesn’t it break the neck weld causing death? You could change the RequiresNeck Humanoid setting to false.

What’s the entire section of script you are using?
Copy/Paste it here with 3 quotes before and after the script (```) so if formats properly.

2 Likes
while wait() do 
  workspace.MagicLuau.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll) 
end

For the death logger in StarterCharacterScript

script.Parent.Humanoid.Died:Connect(function()
	print("Died")
end)

Also i don’t think even if it was the neck the humanoid was supposed to repetly fire died events.

1 Like

But what happens when you try my suggestion?
If the neck joint is trying to weld back together every frame while you are setting it to ragdoll every frame this could be the case.

Why in the heck are you setting it to ragdoll every frame anyway?
The Humanoid ChangeState documentation mentions using SetStateEnabled as well.

1 Like

Still happens when RequireNeck is disabled. You can try it too in your place to confirm

1 Like

Click on the link in my previous post to see what the Roblox documentation has to say.
Also look at SetStateEnabled.

1 Like

Mostly happening when using the reset character button.

Hi, can you please provide a repro file and instructions on how to reproduce the issue? Thanks!

This issue is still happening. Will send a copy to reproduce, there how to replicate.

Client Script for water used:

local Sea = workspace:WaitForChild("Baseplate",30) --Directory of the water part
--
local RS = game:GetService("RunService")
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Root = Character:WaitForChild("HumanoidRootPart")
local Swim


RS.Heartbeat:Connect(function()
	if Root.Position.Y < (Sea.Position.Y + Sea.Size.Y - 6)   - Root.Size.Y / 2 then
		if not Swim then
			Swim = Instance.new("BodyVelocity")
			Swim.Parent = Root
		end
		Swim.Velocity = Humanoid.MoveDirection * Humanoid.WalkSpeed + Vector3.new(0,4,0)
		if Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming then
			Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
			Humanoid:ChangeState(Enum.HumanoidStateType.Swimming)
		end
	elseif Swim and Root.Position.Y < Sea.Position.Y then
		Swim.Velocity = Humanoid.MoveDirection * Humanoid.WalkSpeed
	elseif Swim then
		Swim:Destroy()
		Swim = nil
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
	end
end)

The issue is that you’re changing the state to Swimming every frame, even when the humanoid is in a Dead state. You can fix this by checking for the Dead state:

RS.Heartbeat:Connect(function()
	if Root.Position.Y < (Sea.Position.Y + Sea.Size.Y - 6)   - Root.Size.Y / 2 then
		if not Swim then
			Swim = Instance.new("BodyVelocity")
			Swim.Parent = Root
		end
		Swim.Velocity = Humanoid.MoveDirection * Humanoid.WalkSpeed + Vector3.new(0,4,0)
		local currentState = Humanoid:GetState()
		if currentState ~= Enum.HumanoidStateType.Swimming and currentState ~= Enum.HumanoidStateType.Dead then
			Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
			Humanoid:ChangeState(Enum.HumanoidStateType.Swimming)
		end
	elseif Swim and Root.Position.Y < Sea.Position.Y then
		Swim.Velocity = Humanoid.MoveDirection * Humanoid.WalkSpeed
	elseif Swim then
		Swim:Destroy()
		Swim = nil
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
	end
end)

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