Advertisement
XxxLloyd061302xxX

Leaderboard IF YOU DON'T HAVE ONE

Aug 4th, 2018
13,233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. -- Savable leaderboard?
  2. local ds = game:GetService("DataStoreService"):GetDataStore("--Cash01")
  3.  
  4. game.Players.PlayerAdded:Connect(function(player)
  5.     local key = "cash-"..player.userId
  6.     local folder = Instance.new("Folder",player)
  7.     folder.Name = "leaderstats" -- Must be lowercase
  8.     local currency = Instance.new("IntValue",folder)
  9.     currency.Name = "Cash" -- Name of your currency. Must match with the Currency in the CodeScript.
  10.     currency.Value = 0 -- Starting Cash
  11.    
  12.     local save = ds:GetAsync(key)
  13.     if save then
  14.         currency.Value = save
  15.     end
  16.     currency.Changed:Connect(function()
  17.         ds:SetAsync(key,currency.Value)
  18.     end)
  19. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement