Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DSS = game:GetService("DataStoreService")
- local PointData = DSS:GetDataStore("PointData")
- local PrestigeData = DSS:GetDataStore("PrestigeData")
- function Load(Database, Player)
- local Output = nil
- local S, E = pcall(function()
- Output = Database:GetAsync(Player.UserId)
- end)
- if S then
- return Output
- else
- return 0
- end
- end
- game.Players.PlayerAdded:Connect(function(plr)
- local LB = Instance.new("Folder", plr)
- LB.Name = "leaderstats"
- local p = Instance.new("IntValue", LB)
- p.Name = "Points"
- p.Value = Load(PointData, plr)
- local r = Instance.new("IntValue", LB)
- r.Name = "Prestige"
- r.Value = Load(PrestigeData, plr)
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- PointData:SetAsync(plr.UserId, plr.leaderstats.Points.Value)
- PrestigeData:SetAsync(plr.UserId, plr.leaderstats.Prestige.Value)
- end)
Add Comment
Please, Sign In to add comment