Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How could you make a function run and then ignore it?

Asked by 5 years ago

I have a simple loop that I'm using to run a non stop check. While it sounds inefficient, I've tried all other ways. My issue is that, if conditions match it's supposed to regenerate something at a timed interval. For example:

while true do
wait(1)
local check = false
-- It gets dicey here
if check == true then
addHealth()
wait(1)
addHealth()
wait(1)
addHealth()
check = false
anotherVar = 7
end
-- Ignore here
if anotherVar == 1 then
check = true
end
end

My issue is, that the addHealth() followed by the wait will actually make the loop wait for 3 seconds, as opposed to waiting for 1 second and then continuing. Is there a way to run a function in the loop, and essentially have the loop not wait for that function to continue?

Just a tack on, if there is a way to do what is above, is it possible to check if said function is already running?

0
Please indent your code User#19524 175 — 5y
0
And you want to declare local check outside the loop and before it. Since it's inside, in each iteration you're declaring a local variable named 'check' User#19524 175 — 5y

Answer this question