Advertisement
Guest User

Reddit Roblox LUA Help Guide

a guest
Jul 21st, 2023
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. -- Practice proper naming.
  2. local Players = game:GetService("Players")
  3. local Humanoid = script.Parent.Enemy
  4. -- Just use Once if you'll just remove the script after the Humanoid died.
  5. Humanoid.Died:Once(function()
  6.     local getPlayers = Players:GetPlayers() -- a collection of players.
  7.     for _, plr in pairs(getPlayers) do
  8.         local getLeaderstats = plr:FindFirstChild("leaderstats") -- lets check if leaderstats is available
  9.         if getLeaderstats then
  10.             local Coins = getLeaderstats:FindFirstChild("Coins") -- check if Coins is available inside the leaderstats.
  11.             if Coins then
  12.                 Coins.Value = Coins.Value + math.random(3, 5)
  13.             end
  14.         end
  15.     end
  16.     -- remove the script after done.
  17.     script:remove()
  18. end)
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement