Advertisement
MildlyGaming

Script example

Jan 29th, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. --Basic cash data script
  2.  
  3. local dss = game:GetService("DataStoreService")
  4.  
  5. local store = dss:GetDataStore("cash")
  6.  
  7. game.Players.PlayerAdded:Connect(function(plr)
  8. local fold = Instance.new("Folder", plr)
  9. fold.Name = "leaderstats"
  10.  
  11. local data = store:GetAsync(plr.UserId)
  12.  
  13. if data == nil then
  14. data = 0
  15. end
  16.  
  17. local int = Instance.new("NumberValue", fold)
  18. int.Value = data
  19.  
  20. int.Name = "Cash"
  21. end)
  22.  
  23. while wait(20) do
  24. for i,v in pairs(game.Players:GetChildren() do
  25. v.leaderstats.Cash.Value += 100
  26. end
  27. end
  28.  
  29. game.Players.PlayerRemoving:Connect(function(plr)
  30.  
  31. store:SetAsync(plr.UserId, plr.leaderstats.Cash.Value)
  32. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement