PresterStudios

Reward All Players - Roblox Scripts

Jun 1st, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. -- module
  2.  
  3. local module = {}
  4.  
  5. function module.RewardAllPlayers(giver,amount)
  6.    
  7.     local totalSubstract = (amount * #game.Players:GetPlayers())
  8.    
  9.     if giver.leaderstats.Cash.Value > totalSubstract then
  10.        for _, player in pairs(game.Players:GetChildren()) do
  11.            
  12.             player.leaderstats.Cash.Value += amount
  13.             giver.leaderstats.Cash.Value -= (amount*2) -- if you want all players to get money when this function runs (includes the giver) delete this line.
  14.            
  15.             print(giver.Name .." donated ".. amount .." to all players!")
  16.            
  17.        end    
  18.     end
  19. end
  20.  
  21. return module
  22.  
  23. -- module script end.
  24.  
  25. -- example (in normal script inside ServerScriptService)
  26.  
  27. local module = require(game.ServerScriptService.ModuleScript)
  28.  
  29. wait(3)
  30.  
  31. module.RewardAllPlayers(
  32.     plr, -- giver (the one who donated)
  33.     amount -- the amount that will be donated to ALL players (except for the sender)
  34. )  
Advertisement
Add Comment
Please, Sign In to add comment