I'm making a script where when the humanoid dies, then it awards him/her points. However, it doesn't. Help?
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() player.leaderstats.Explosions.Value = game.Players.LocalPlayer.leaderstats.Explosions.Value + 1 player.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value + 10 end) end) end)
PlayerAdded
runs when a new player joins the game. However, the local script runs instantly, so it would instead wait for another player to join. You shouldn't be using PlayerAdded
on the client anyways. Just place your script in a server script in `Servergame:GetService('Players').PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() player.leaderstats.Explosions.Value = game.Players.LocalPlayer.leaderstats.Explosions.Value + 1 player.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value + 10 end) end) end)
:Connect()
as :connect()
is deprecated and should not be used in new work.