Untitled

 avatar
user_1052705
plain_text
a year ago
604 B
7
Indexable
local DTS = game:GetService("DataStoreService")
local PointsStore = DTS:GetDataStore("Points")

game.Players.PlayerAdded:Connect(function(Player)
	local LeaderstatsFolder = Instance.new("Folder", Player)
	LeaderstatsFolder.Name = "leaderstats"
	
	local Points = Instance.new("IntValue", LeaderstatsFolder)
	Points.Name = "Points"
	
	local CurrentPoints = PointsStore:GetAsync(Player.UserId)
	
	if CurrentPoints == nil then
		CurrentPoints = 0
	end
	
	Points.Value = CurrentPoints
	
	Points.Changed:Connect(function(NewValue)
		PointsStore:SetAsync(Player.UserId, NewValue)
	end)
end)
Editor is loading...
Leave a Comment