SHARE
TWEET

BmanBob's saving-script

bmanbob Oct 21st, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local datastore = game:GetService("DataStoreService"):GetDataStore("test866818286369716235195685453434369464701")
  2.  
  3. game.Players.PlayerAdded:Connect(function(player)
  4.     local lt = Instance.new("Folder")
  5.     lt.Name = "leaderstats"
  6.     lt.Parent = player
  7.    
  8.     local money = Instance.new("IntValue")
  9.     money.Name = "Cash"
  10.     money.Parent = lt
  11.    
  12.     local key = "plr-"..player.userId
  13.    
  14.     local getSaved = datastore:GetAsync(key)
  15.     if getSaved then
  16.         money.Value = getSaved[1]
  17.     else
  18.         local itemsToSave = {money.Value}
  19.         datastore:GetAsync(key, itemsToSave)
  20.     end
  21. end)
  22.  
  23. game.Players.PlayerRemoving:Connect(function(player)
  24.     datastore:SetAsync("plr-"..player.userId, {player.leaderstats.Cash.Value})
  25. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top