Advertisement
Robloxianbuilder

leaderboard

Apr 1st, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. local DataStoreService = game:GetService("DataStoreService")
  2. local DataStore = DataStoreService:GetDataStore("MoneyStats") -- Change this with a random name.
  3.  
  4. game.Players.PlayerAdded:Connect(function(Player)
  5. local Leaderstats = Instance.new("Folder")
  6. Leaderstats.Name = "leaderstats"
  7. Leaderstats.Parent = Player
  8. local Currency = Instance.new("StringValue")
  9. Currency.Name = "Money" -- Change this with your currency name.
  10. Currency.Value = DataStore:GetAsync(Player.UserId) or "0"
  11. Currency.Parent = Leaderstats
  12. end)
  13.  
  14. game.Players.PlayerRemoving:Connect(function(Player)
  15. DataStore:SetAsync(Player.UserId, Player.leaderstats.Money.Value)
  16. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement