Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- module
- local module = {}
- function module.RewardAllPlayers(giver,amount)
- local totalSubstract = (amount * #game.Players:GetPlayers())
- if giver.leaderstats.Cash.Value > totalSubstract then
- for _, player in pairs(game.Players:GetChildren()) do
- player.leaderstats.Cash.Value += amount
- giver.leaderstats.Cash.Value -= (amount*2) -- if you want all players to get money when this function runs (includes the giver) delete this line.
- print(giver.Name .." donated ".. amount .." to all players!")
- end
- end
- end
- return module
- -- module script end.
- -- example (in normal script inside ServerScriptService)
- local module = require(game.ServerScriptService.ModuleScript)
- wait(3)
- module.RewardAllPlayers(
- plr, -- giver (the one who donated)
- amount -- the amount that will be donated to ALL players (except for the sender)
- )
Advertisement
Add Comment
Please, Sign In to add comment