Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Practice proper naming.
- local Players = game:GetService("Players")
- local Humanoid = script.Parent.Enemy
- -- Just use Once if you'll just remove the script after the Humanoid died.
- Humanoid.Died:Once(function()
- local getPlayers = Players:GetPlayers() -- a collection of players.
- for _, plr in pairs(getPlayers) do
- local getLeaderstats = plr:FindFirstChild("leaderstats") -- lets check if leaderstats is available
- if getLeaderstats then
- local Coins = getLeaderstats:FindFirstChild("Coins") -- check if Coins is available inside the leaderstats.
- if Coins then
- Coins.Value = Coins.Value + math.random(3, 5)
- end
- end
- end
- -- remove the script after done.
- script:remove()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement