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)
Hey, The problem was that in line 19 you are using UpdateAsync(), you should use SetAsync()
I fixed for you:
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:SetAsync(player.UserId,player.leaderstats.Points.Value) end)
Make sure you have enabled Studio Access to API Services
If you got any further problems please comment on this answer and I will do my best to help.