Sr_Guizinho

Primeiro script da parte 1

Feb 27th, 2021 (edited)
1,416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local DSS = game:GetService("DataStoreService")
  2. local PointData = DSS:GetDataStore("PointData")
  3. local PrestigeData = DSS:GetDataStore("PrestigeData")
  4.  
  5. function Load(Database, Player)
  6.     local Output = nil
  7.  
  8.     local S, E = pcall(function()
  9.         Output = Database:GetAsync(Player.UserId)
  10.     end)
  11.  
  12.     if S then
  13.         return Output
  14.     else
  15.         return 0
  16.     end
  17. end
  18.  
  19. game.Players.PlayerAdded:Connect(function(plr)
  20.     local LB = Instance.new("Folder", plr)
  21.     LB.Name = "leaderstats"
  22.  
  23.     local p = Instance.new("IntValue", LB)
  24.     p.Name = "Points"
  25.     p.Value = Load(PointData, plr)
  26.  
  27.     local r = Instance.new("IntValue", LB)
  28.     r.Name = "Prestige"
  29.     r.Value = Load(PrestigeData, plr)
  30. end)
  31.  
  32. game.Players.PlayerRemoving:Connect(function(plr)
  33.     PointData:SetAsync(plr.UserId, plr.leaderstats.Points.Value)
  34.     PrestigeData:SetAsync(plr.UserId, plr.leaderstats.Prestige.Value)
  35. end)
Add Comment
Please, Sign In to add comment