I don't know what I've done wrong, I've played it in the real game and in the studio one and it won't work, I enabled api stuff in studio but it still doesn't work.
local ds = game:GetService("DataStoreService"):GetDataStore("Points")
game.Players.PlayerAdded:connect(function(player)
-- datastore stuff
game.ServerStorage.leaderstats:Clone().Parent = player
local PointsValue = ds:GetAsync(player.UserId)
if PointsValue then
player.leaderstats.Points.Value = PointsValue else
player.leaderstats.Points.Value = 0
end
while wait(5) do
player.leaderstats.Points.Value = player.leaderstats.Points.Value + 300
end
end)
game.Players.PlayerRemoving:connect(function(player)
ds:UpdateAsync(player.UserId,player.leaderstats.Points.Value)
end)

3 comments
Please post your error.
As far I can see, you are using updateasync instead of setasync.
setasync will have cache sometimes and get async will get the wrong value, fixed it btw