Goal; The goal is to fire an event whenever a player die. The event is suppose to anchor the whole character, make it black and delete everything that isn’t a body part.
Issue; The event isn’t firing.
What I’v tried; I tried to make a while loop that check if the humanoid’s life is equal to 0 and then fire all of the script, and to not make studio crash I added a timer, but it needed to fire exactly when a player die so it wasn’t a good idea. So I added this event firing script, but it’s not working.
It’s a local script in the starter player script.
-- part that make an event fire when the player die
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
-- event when the player die
print("Player "..player.." has died")
for i, v in pairs(character:GetDescendants()) do
if v:IsA("BasePart") then
print(v)
v.Anchored = true
v.CanCollide = false
v.Color = Color3.fromRGB(0,0,0)
else if v:IsA("Shirt") or v:IsA("ShirtGraphic") or v:IsA("Pants") or v:IsA("Decal") or v:IsA("Accessory") then
print(v)
v:Destroy()
end
end
end
end)
end)
end)
Humanoid.Died has just been a piece of trash whenever I try and use it. It’s extremely unreliable. Try to use the GetPropertyChangedSignal on the health value of the humanoid, and just check for whenever the humanoid’s health is less than or equal to 0.
The event can delay for up to a minute when used on the server. GetPropertyChangedSignal has little to no delay on the server nor client.
@anon24371531 answer is most likely the solution, however I would still advise switching over to GetPropertyChangedSignal, especially if this is a ServerScript.
That’s interesting and probably true , thanks for pointing this out. Seems like all, or most Humanoid properties seem to be bad(?) and I can vouch for this with especially Humanoid.FloorMaterial as an example:
Delaying up to a minute? That’s not how it works? Delays aren’t caused by the event if it’s ping then I don’t see why GetPropertyChangedSignal wouldn’t either???
Alright I’ll tell you reason why it’s not working. Since it’s a localscript it can’t even detect if the localplayer has joined because it is cloned when the player has already joined. Best to use a server script.
Great, but I had to change the script like this to make the body part anchor right after the humanoid death, from what I see from you’r video, there is a little bit of latency. As mentionned before, I will probably try with GetPropertyChangedSignal. Thanks!