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

HiWhat to replace "while" with?

Hi, so I have this script and the "while" code word is preventing the rest of the script from running. What do I need to change to fix it?

local time = 

while wait(0.3) do
	time = time + 1  	
	if time >= 0 and time <= 13 then
		script.Parent.Text = "Welcome To Freeze Tag Reborn"
	elseif time >= 13 and time <= 28 then
		script.Parent.Text = "Adding you to server..."
	elseif time >= 28 and time <= 33 then
		script.Parent.Text = "Loading the game..."
	elseif time >= 33 and time <= 46 then
		script.Parent.Text = "Getting game info..."
	elseif time >= 46 and time <= 51 then
		script.Parent.Text = "Checking saved data..."
	elseif time >= 51 and time <= 60 then
		script.Parent.Text = "Loading Player Settings"
	elseif time >= 60 and time <= 79 then
		script.Parent.Text = "Throwing Puppy Guarders Into BanLand"
	elseif time >= 79 and time <= 86 then
		script.Parent.Text = "Getting other players..."
	elseif time >= 86 and time <= 92 then
		script.Parent.Text = "Loading player..."
	elseif time >= 92 and time <= 100 then
		script.Parent.Text = "Have Fun!"
	end
end

1 comment

1

Add a 0 after "local Time = " and reply if it works or not.

1 answer

✓ Accepted answer

When code is executed, it continues in a sequential order (such that each line is only executed after the previous one has finished executing). The while loop will continue to loop over and over again until its condition becomes false or break is called inside it.

Your condition always evaluates to false, and therefore it will continue forever. So what does this mean for any code that appears after the loop? The Lua interpreter will never be able to execute it because the previous line (the while loop) will never finished executing.

If you want your loop to continue forever, any code that you want to run will have to be written before the loop so that the interpreter can execute it.

1 comment

0

always elvaluates to true*

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