Sorry I am new so I'm not that good at explaining my scripts.
------ sorry if this is a bad script or I did not do a good job explaining it im new so im not that good.
PointData = game:GetService("DataStoreService"):GetDataStore("PointData")-------I dont really know what these do I just know they are important.
Bought = game:GetService("DataStoreService"):GetDataStore("Bought")-------- same thing here.
game.Players.PlayerAdded:Connect(function(plr)-------This runs when a new player is added.
local LB = Instance.new("IntValue")
LB.Name = "leaderstats"
local p = Instance.new("IntValue")---------this adds the Points to the new players leader board
p.Name = "Points"
p.Value = PointData:GetAsync(plr.userId) or 0
local r = Instance.new("IntValue")------------This addes the Bought variable to the leaderboard of the new player. I use the bought one to keep track and save what is bought im a new programer.
r.Name = "Bought"
r.Value = Bought:GetAsync(plr.userId) or 0
LB.Parent = plr
p.Parent = LB-------------these assing the points the Bought and the Leaderboard to the player.
r.Parent = LB
end)
game.Players.PlayerRemoving:Connect(function(plr)
PointData:SetAsync(plr.userId, plr.leaderstats.Points.Value)--------I think these take the players leaderboard thing off when they leave.
Bought:SetAsync(plr.userId, plr.leaderstats.Bought.Value)
end)
