REDPlays

Working with Data Stores

Jul 15th, 2018
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local DataStore = game:GetService("DataStoreService")
  2. local DS1 = DataStore:GetDataStore("Customization")
  3.  
  4.  
  5.  
  6. game.Players.PlayerAdded:connect(function(plr)
  7.     local Character = plr
  8.     print(Character)
  9.    
  10.     local SValue = Instance.new("NumberValue",Character)
  11.     SValue.Name = "SValue"
  12.     SValue.Value = DS1:GetAsync(plr.UserId)
  13.    
  14.     local PValue = Instance.new("NumberValue",Character)
  15.     PValue.Name = "PValue"
  16.     PValue.Value = DS1:GetAsync(plr.UserId)
  17.    
  18.     local FValue = Instance.new("NumberValue",Character)
  19.     FValue.Name = "FValue"
  20.     FValue.Value = DS1:GetAsync(plr.UserId)
  21.    
  22.    
  23.     SValue.Changed:connect(function()
  24.         print("Saving Data..")
  25.         DS1:SetAsync(plr.UserId, SValue.Value)
  26.         print("Data Saved")
  27.     end)
  28.    
  29.     PValue.Changed:connect(function()
  30.         print("Saving Data..")
  31.         DS1:SetAsync(plr.UserId, PValue.Value)
  32.         print("Data Saved")
  33.     end)
  34.    
  35.     FValue.Changed:connect(function()
  36.         print("Saving Data..")
  37.         DS1:SetAsync(plr.UserId, FValue.Value)
  38.         print("Data Saved")
  39.     end)
  40. end)
Advertisement
Add Comment
Please, Sign In to add comment