I am currently developing a program that awards points to players and grants them cash after a 5-second interval. However, the program currently has a flaw wherein points and cash are being awarded simultaneously, rather than one after the other. I am seeking a solution to address this issue and ensure that points and cash are granted separately, as intended.
Here’s the code!
while Started.Value == true do
Time.Value += 1
if Time.Value > BestTime.Value then
BestTime.Value = Time.Value
end
wait(5) do
Folder2.Token.Value += 1
end
end
I apologize, what I’m looking for a code where no matter what is waiting (I.e. Token), it’ll give the seconds instead of waiting a additional 5 seconds just to get +1 time.
while Started.Value == true do
Time.Value += 1
if Time.Value > BestTime.Value then
BestTime.Value = Time.Value
end
task.wait(5)
Folder2.Token.Value += 1
end
First, It’ll give time once, wait 5 seconds, give token, and repeat. (There’s a pause where it doesn’t give the time once, (Like every 1 second it’ll give time).
while Started.Value == true and task.wait(1) do
Time.Value += 1
if Time.Value > BestTime.Value then
BestTime.Value = Time.Value
end
delaly(5, function()
Folder2.Token.Value += 1
end
end
Not quite sure if this is what you’re asking for, but here:
while Started.Value == true and task.wait(1) do
Time.Value += 1
if Time.Value > BestTime.Value then
BestTime.Value = Time.Value
end
if Time.Value % 5 == 0 then
Folder2.Token.Value += 1
end
end
I could be totally wrong here with interpreting your question, but I want to offer this to hopefully nudge you in the right direction.
In fact, @kittyPGR has already done the same thing. But it sounds like you want your main while loop to continue running even though you are still waiting for 5 seconds. You don’t want the waiting to halt the while loop.
For that, you would need to create a new coroutine to run that code seperately from the while loop.
Like:
task.delay(5, function()
– Stuff to do after 5 seconds
end)
But I would refer to @kittyPGR 's code for what your code should look like. They also added in a “wait” for one second as well. So keep that in mind.
Also, if you don’t want to your “Token += 1” code to always happen after 1 second, you would also need to put it within another if statement, but I don’t know if the Time.Value > BestTime.Value is where you would want to put that. But I’m just saying in the event another issue arrises on your end.
The issue is you increment time, wait 5 seconds, increment token and then immediately go back to time again because the loop ends. Just add another wait(5) after Folder2.Token.Value += 1