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:
Create 1 server with 1 player
Watch how Dead state is triggered on server
Alt. comment out the SetStateEnabled on server, still same results.
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?)
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.
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.
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.