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

While loop not working but while true loop does?

Why does this not work:

while itemName.Value ~= "none" do
	wait(.0001)
	print("item value is not none")
	gui.Visible = true
	gui.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
end

While this does:

while true do
	wait(.0001)
	if itemName.Value ~= "none" then
		gui.Visible = true
		gui.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
	end
end

1 comment

0

forgot to mention i've set this to run when it does not equal to "none" and on default it is something else.

2 answers

✓ Accepted answer

The second script will keep looping regardless wether (itemName.Value ~= "None") results in true or false

Since the condition for the while loop will always be true

The first script however use (itemName.Value ~= "none") as its condition, which means once (itemName.Value ~= "none") resulted in false, the script will stop running

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