Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How check if a value == 1 while is waiting 120 secs?

I mean,i want that,while the script is waiting: wait (120),check if Mision.Value == 1,if it is while the time is running,send a message,this is the script

while true do
if workspace.Mision.Value == 1 then 


local c2 = Instance.new ("Message")
c2.Text = "Gas Station Call"
c2.Parent = game.Workspace
c2.Text = "All clear"


else    
    wait (120)
end

end

1 answer

✓ Accepted answer

Here try this:

local count = 0

while true do
	wait(1)
	count = count + 1
	if workspace.Mision.Value == 1 then
		local c2 = Instance.new ("Message")
		c2.Text = "Gas Station Call"
		c2.Parent = game.Workspace
		c2.Text = "All clear"
	elseif count >= 120 then -- 
		break -- completely stops the script
	end
end

if that doesn't work then:

local count = 0

while count < 120 do
	wait(1)
	count = count + 1
	if workspace.Mision.Value == 1 then
		local c2 = Instance.new ("Message")
		c2.Text = "Gas Station Call"
		c2.Parent = game.Workspace
		c2.Text = "All clear"
	end
end

Hopefully this helped!

Best of luck developer!

2 comments

0

You misspelled end on line 11 of Second Script. Small mistake but worth fixing.

0

thanks for reminder

This discussion is preserved as it was. New answers, comments, and votes are closed.