Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local groupID = 2929563
- local dss = game:GetService("DataStoreService")
- local rewardsDS = dss:GetDataStore("GroupRewards")
- function saveData(plr)
- rewardsDS:SetAsync(plr.UserId .. "Cash", plr.leaderstats.Cash.Value)
- end
- game.Players.PlayerAdded:Connect(function(plr)
- local ls = Instance.new("Folder")
- ls.Name = "leaderstats"
- ls.Parent = plr
- local cash = Instance.new("IntValue")
- cash.Name = "Cash"
- cash.Parent = ls
- local cashData = rewardsDS:GetAsync(plr.UserId .. "Cash") or 0
- local hasClaimed = rewardsDS:GetAsync(plr.UserId .. "Claimed")
- cash.Value = cashData
- if plr:IsInGroup(groupID) and not hasClaimed then
- rewardsDS:SetAsync(plr.UserId .. "Claimed", true)
- cash.Value += 100
- end
- end)
- game.Players.PlayerRemoving:Connect(saveData)
- game:BindToClose(function()
- for i, plr in pairs(game.Players:GetPlayers()) do
- saveData(plr)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement