Untitled

 avatar
user_1052705
plain_text
a month ago
604 B
4
Indexable
Never
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)
Leave a Comment