Event not firing [ H E L P ]

Hello, I need help with this script.

  1. 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.

  2. Issue; The event isn’t firing.

  3. 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)

Thanks in advance, have a good day.

Which type of script is it localscript or serverscript?

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.

GetPropertyChangedSignal

1 Like

It really isn’t trash as it works flawlessly for me, you might be using it wrong.

It’s firing but not working because of your print message, you’re trying to concatenate an Instance in a string.

print("Player "..player.." has died")

It should be player.Name

2 Likes

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.

1 Like

That’s interesting and probably true :+1:, 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:

Humanoid.FloorMaterial not filtered well when near others - Bug Reports / Engine Bugs - DevForum | Roblox

1 Like

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???

You’re right. That’s not how it’s supposed to work, but it does unfortunately for a lot people.

Please see RawBlocky’s response in this post:
Humanoid.Died Delay

I’ve already provided my reasoning for why it’s unreliable. I don’t know what more you want me to get for you.

It’s a localscript on the starter player script but maybe now I should moov it actually

Oh thanks I didn’t know this existed, it’s going to help me a lot.

Oh that’s possible, i’ll try it ASAP, but I just wrote “player” because sometimes you don’t need to write .Name.

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.

This is true. I also just replaced it in your code and it works fine for me. Outcome:

Oh my… Yes you’r right, thanks. I didn’t even thought about it.

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!