Advertisement
RoScripter

Points System

Nov 28th, 2020
5,288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.67 KB | None | 0 0
  1. local DataStoreService = game:GetService("DataStoreService")
  2. local PointsStore = DataStoreService:GetDataStore("PointsStore")
  3.  
  4. game.Players.PlayerAdded:Connect(function(Player)
  5.     local SavedPoints = PointsStore:GetAsync(Player.UserId)
  6.    
  7.     local Leaderstats = Player:FindFirstChild("leaderstats") or Instance.new("Folder", Player)
  8.     Leaderstats.Name = "leaderstats"
  9.    
  10.     local PointsValue = Leaderstats:FindFirstChild("Points") or Instance.new("IntValue", Leaderstats)
  11.     PointsValue.Name = "Points"
  12.    
  13.     if SavedPoints ~= nil then
  14.         PointsValue.Value = SavedPoints
  15.     end
  16.    
  17.     PointsValue.Changed:Connect(function(NewPoints)
  18.         PointsStore:SetAsync(Player.UserId, NewPoints)
  19.     end)
  20. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement