Hey, is there a way to check if a certain variable is true for lets say 30 seconds and if it is it fires something. Im struggling because im not sure how to do it…
Thanks!
Hey, is there a way to check if a certain variable is true for lets say 30 seconds and if it is it fires something. Im struggling because im not sure how to do it…
Thanks!
local time = 0
local TrueValue= true
while Task.wait(1) do
time +=1
if TrueValue and time ~= 30 then continue end
–Rest of the code
return
end
You can actually combine that in a While true do and keep checking the time passed is less than the amount you want:
local variable = true -- This is the variable you want to check
local Duration = 10 -- time in seconds
local passedTime = 0 -- time passed
local function checkVariable()
while passedTime < Duration do
if not variable then
print("Variable is no longer true.")
return
end
task.wait(1)
passedTime += 1
end
-- ur script here
end
checkVariable()
It doesnt seem to work and im not getting any errors in the output?
its also because the value is already false not true
the value is true, if it became false, it will return and print this Variable is no longer true.
yes but the variable in my situation starts as false
Never Mind I changed the script a bit and it works now! Thanks!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.