so I'm trying to make a system that gives you 1 money per minute, but I wanted it to work and give you the amount equal to however long they were gone divided by 60, and then rounded down, thus giving me how many minutes they were gone, and I would then give them 1 money for every minute they were gone.
I have the more part of the script written, but the issue I have is that it either doesn't work without having any errors, or it doesn't wait the 60 seconds to give it to me, so I'm stuck getting either nothing, or getting about 10 money per second when I only want 1 money per minute.
this is my code so far (I'm new to scripting so please don't be to harsh on my bad code) :
local players = game:GetService("Players")
local playTable = {}
local ticktable = {}
game.Players.PlayerAdded:Connect(function(player)
table.insert(playTable, #playTable+1, player.Name)
table.insert(ticktable, #ticktable+1, tick())
end)
while true do
wait()
for table1 = 1, #ticktable, 1 do
if tick() - ticktable[table1] == 60 then
local payperson = playTable[table1]
ticktable[table1] = tick()
print("paid ".. payperson)
players:WaitForChild(payperson).leaderstats.Money.Value = players:WaitForChild(payperson).leaderstats.Money.Value + 1
end
end
end
I've put it all inside a script in ServerScriptService. please help me, all I really need to know is how to fix the If statment actually stops the for loop and runs the code inside. Thanks :)

3 comments
for some reason it still doesn't give me the money, or an error in the output, and I directly copied the code you sent into the script.
Just updated my answe with a working script. it just simply rounds off the tick() function. Hope this helps!
you had a simple typo, it needed to be >= not == when checking what the time was, but yes it does work now tysm