Hello community, I am using this Script to get a Leaderboard with auto-save. But now I need to generate money every few seconds, it would be interesting and of good gratitude if you can give me a Script for the aforementioned keeping the previous 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)
Hello Ghost_Gamer1, to make a cash giver like you sent, you need to use a repetion.
while wait(1) do leader.money.Value = leader.money.Value + 1 end
The first 1 in the wait is the time that waiting. The second at the line two is the number cash added.
Put this under the line 15
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 while wait(1) do leader.money.Value = leader.money.Value + 1 end end)
Just change "money" for your type money name
To more question, put below.