I put this script inside a NPC with a humanoid inside it and this is a SS script
local plr = game.Players.LocalPlayer
if script.Parent.Humanoid.Health == 0 then
plr.leaderstats.Currency.Value = plr.leaderstats.Currency.Value + 10
end
I put this script inside a NPC with a humanoid inside it and this is a SS script
local plr = game.Players.LocalPlayer
if script.Parent.Humanoid.Health == 0 then
plr.leaderstats.Currency.Value = plr.leaderstats.Currency.Value + 10
end
Add a server script into serverscriptservice and use this code
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char:WaitForChild("Humanoid").Died:Connect(function()
player.leaderstats.Currency.Value += 10
end)
end)
end)
So we are functioning when a player joins and check when the character joins so we can run a function to check when the player dies and when they do we are gonna reward the player some currency
you didnt even care to explain to a beginner.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
ServerScripts cannot run the local player
Also, you should not use an if statement because it will run only once when the script is made. This will cause it to be false at the start and when a player kills the NPC, it wont run again.