✓ Accepted answer
FlaminSparrow and Necrorave's answer would work, but there's a much better way of doing this.
I'm mostly just building upon their answers. Great job guys!
Instead of using a LocalScript in StarterGui, use a regular script in ServerScriptService.
"But how?"
Use embedded functions!
You can do this by connecting function within other functions. Here's my solution,
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local Humanoid = char:WaitForChild("Humanoid")
Humanoid.Died:connect(function()
print(plr.Name.." Died")
end)
end)
end)
I understand you might not know how this works, but learn from it.
When the function happens, it gives you a variable like the player, or player's character. These variables can be used to make new functions.
That should do it
Good Luck!
2 comments
Use the Lua icon to place your code in.
Thanks for the accept! <3