I watched alot of youtube tutorial I read documentation. I turn on api services but still It doesn’t save.
local DataStoreService = game:GetService("DataStoreService")
local ds1 = DataStoreService:GetDataStore("PointsSaveSystem")
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = plr
local points = Instance.new("IntValue")
points.Name = "Points"
points.Parent = folder
local success, value = pcall(function()
return ds1:GetAsync(plr.UserId)
end)
if success and value then
points.Value = value
else
points.Value = 0
end
points.Changed:Connect(function()
local _, setValueError = pcall(function()
ds1:UpdateAsync(plr.UserId, function(oldValue)
return points.Value
end)
end)
if setValueError then
warn("Error updating DataStore:", setValueError)
end
end)
end)