Advertisement
RoScripter

Points System

Jun 2nd, 2020
5,698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 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 = Instance.new("Folder", Player)
  8.     Leaderstats.Name = "leaderstats"
  9.    
  10.     local PointsValue = 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