Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I detect when a player dies?

local ID = 131149175

game.Players.PlayerAdded:connect(function(Player)
	wait(1)
	Player.Character.Humanoid:Died():connect(function()
		local s = Instance.new("Sound", Player:WaitForChild("PlayerGui"))
		s.SoundId = "rbxassetid://" ..ID.. ""
		s.Looped = true
		s:Play()
	end)
end)

I am trying to make it play a sound when the player dies. 21:44:16.199 - ServerScriptService.Script:5: attempt to call method 'Died' (a userdata value) 21:44:16.201 - Stack Begin 21:44:16.203 - Script 'ServerScriptService.Script', Line 5 21:44:16.205 - Stack End

1 comment

0

Oh, and the only thing you did wrong was "()" beside Died on line 5

1 answer

✓ Accepted answer
wait(4) -- Let errythin load
while wait() do
	for i, v in pairs(game.Players:GetChildren()) do
		repeat wait() until v.Character ~=nil
 		local Char = v.Character
		local Hum = Char:FindFirstChild("Humanoid")
		Hum.Died:connect(function()
			print(v.Name .. " Has Died :(")
		end)
	end
end

4 comments

0

Deputy, what does the v and i mean in your script?

0

Doesn't work at all...

0

Ok, think back to 6th grade science. I is the independent and v is the dependent. i is the # of which the child is in Players and v is the actual thing.

0

Sorry, I fixed it just in case you want to use this one too cx

This discussion is preserved as it was. New answers, comments, and votes are closed.