SetStateEnabled(Dead, false) doesnt work [incl. Repro]

Problem
Even if you’ve done
humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
on both server and client, Dead event will still trigger on server if the damage is applied on serverside.

How to repro:

  1. Create 1 server with 1 player
  2. Watch how Dead state is triggered on server

Alt. comment out the SetStateEnabled on server, still same results.

Repro: SetStateEnabledBug.rbxl (14.0 KB)

9 Likes

A simple fix with states appears to be repeatedly setting them, is that something you tried? (as in setting the state as disabled every heartbeat)

It seems to be solved by reseting to previous state as soon as the dead state is triggered but it’s a workaround, not a solution.

2 Likes

Also getting this in my game and it’s causing a lot of weird behaviour. Glad to see it’s not just me.

To explain the behaviour in my game;

  • I use the default R15 rig.

  • I only ever call LoadCharacter() once - I simply retrofit the existing character in order to save memory. This means that unless their character loses a limb or something, they will continue to have the same Humanoid throughout.

  • In order to use this system, I disable the Dead state every time they ‘spawn’ in. This ensures that the rig is intact when I use it again.

  • Very recently (since 17th/18th May), the animation that played on death would only play sometimes, and the character would fall apart on death.

  • To my knowledge, and according to player testimony, this had not been happening previously. I did not change any code relating to my system, so this appears to be brought on by an engine change.

  • In addition, players would spawn in as invisible for certain players (presumably due to the client thinking the Dead state is disabled and other clients not having caught up?)

1 Like

This would definitely be nice to have fixed. I’ve had a lot of problems with it and the fact that it doesn’t work as intended is very confusing and frustrating.

3 Likes

I have a fix in the pipeline. :smile:

11 Likes

praise red man

looking forward to seeing my game working nice again, will let you know how it fares when this ships :+1:

5 Likes

If this fixes my ragdolls breaking then you’re my new favorite roblox employee!

Right after zeuxcg ofc :smile:

3 Likes

Well that goes without saying.

3 Likes

This should be fixed now.

10 Likes

Glad you fixed it. My game will require this in order for the AIs to ragdoll properly.

2 Likes

Does this means that SetStateEnabled is fixed all the HumanoidStates when set?

and

Do I have to SetStateEnabled on both Client & Server or just one?


I’m a bit confused after reading every post in this thread

What happened before and what will happen now when you Test the Repro?

Yes, you should set it on both Server and Client.
SetStateEnabled does not replicate, and the server and client each have different responsibilities when it comes to humanoid states.

In the case of Enum.HumanoidState.Dead, the client is what handles your “falling apart”, but the server is what respawns you after 5 seconds.

However, most states are done on the client. To be on the safe side, set them on both server and client.

Before the change, the server would detect the character in the “Dead” state and respawn your character after 5 seconds. This shouldn’t happen anymore.

7 Likes

Right that is what I have been experiencing too, Thank you for fixing that :+1:

@Osyris This isn’t fixed at all.


Repro.rbxl (240.8 KB)

(Press E to Enter Dead State, using LocalScript)

To briefly explain;

If you do

Hum:SetStateEnabled(Dead,false)
Hum:ChangeState(Dead)

On the Server the Humanoid won’t die, which is expected behavior.
However if you do that in the Client the Humanoid will always die.

In conclusion the Client Overrides the Humanoid’s Dead State no matter what.

(I haven’t tested with all of the other State Types, but if it happens for all of them then this is really bad)

Code

Server-Side

local PlayerS = game:GetService('Players')

local Dead = Enum.HumanoidStateType.Dead

PlayerS.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(Cha)
		local Hum = Cha:WaitForChild('Humanoid')
--		Hum:SetStateEnabled(Dead,false)
--		print("Server",Hum:GetStateEnabled(Dead))
		Hum:ChangeState(Dead)
		Hum.Died:Connect(function()
			print("Server Hum.Died")
		end)
	end)
end)

If you Uncomment the Commented code you’ll see that the Player will never respawn.


Client-Side

local PlayerS = game:GetService('Players')
	local plr = PlayerS.LocalPlayer
		local Cha = plr.Character or plr.CharacterAdded:Wait()
			local Hum = Cha:WaitForChild('Humanoid')

local ContextActionS = game:GetService('ContextActionService')

local Dead = Enum.HumanoidStateType.Dead

Hum:SetStateEnabled(Dead,false)
print("Client",Hum:GetStateEnabled(Dead))
wait(1); Hum:ChangeState(Dead)
Hum.Died:Connect(function()
	print("Client Hum.Died")
end)

plr.CharacterAdded:Connect(function(Cha)
	Hum = Cha:WaitForChild('Humanoid')
	Hum:SetStateEnabled(Dead,false)
	print("Client",Hum:GetStateEnabled(Dead))
--	wait(1); Hum:ChangeState(Dead)
	Hum.Died:Connect(function()
		print("Client Hum.Died")
	end)
end)

ContextActionS:BindAction("SetStateEnabled",function(_,State)
	if State == Enum.UserInputState.Begin then
		print("Client",Hum:GetStateEnabled(Dead))
		Hum:ChangeState(Dead)
	end
end,false,Enum.KeyCode.E)

If you Uncomment the Commented code you’ll see that the Player will respawn again and again and again.

2 Likes