#making a script to print died when a player dies

3 messages · Page 1 of 1 (latest)

wild badger
#

so i would like to make a script which prints when a player dies but for some reason i cant menage to get the humanoid object from my player object

local players = game:GetService("Players")

local function onDeath() 

end

local function onPlayerAdded(player)
    players:WaitForChild("Humanoid").Died:Connect(onDeath())
end


players.PlayerAdded:Connect(onPlayerAdded)

when i run the game i get this error:

  14:15:36.205  Infinite yield possible on 'Players:WaitForChild("Humanoid")'  -  Studio
  14:15:36.205  Stack Begin  -  Studio
  14:15:36.205  Script 'ServerScriptService.Script', Line 8 - function onPlayerAdded  -  Studio - Script:8
  14:15:36.205  Stack End  -  Studio
#

alr thank you

#

worked thanks