Hey so I have a datastore script which saves the leaderstat, the name of it is a value which is the child of the script, I need the leaderstat to go up by 500 every 60 seconds.
Here is the script:
game.Players.PlayerAdded:connect(function(player)
local DataStore = game:GetService("DataStoreService")
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
for i,v in pairs(script:GetChildren()) do
local d = DataStore:GetDataStore(v.Name)
local x = Instance.new("NumberValue",leader)
x.Name = v.Name
x.Value = d:GetAsync(player.UserId) or v.Value
end
end)
game.Players.PlayerRemoving:Connect(function(player)
for i,v in pairs(script:GetChildren()) do
print("Getting")
local DataStore = game:GetService("DataStoreService")
local d = DataStore:GetDataStore(v.Name)
d:SetAsync(player.UserId, player.leaderstats[v.Name].Value)
print("Saved")
end
end)
Thanks

2 comments
bruh you didn't even try, this isn't a request site
I did, I used while true do etc and it didnt work