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

while true do attemp error?

I put two Loops (While true do) in a script, but one of them (the last one) doesn't work ... it doesn't print '' hello ''. I don't know what is happening script:

wait(game.Players.PlayerAdded)
verdade = false
applevalue = game.Workspace.appleintvalue
applevalue.Value = 0
applescripton = true
^while applescripton == true do
..(while true do comand)

while true do
	wait()
	print('hello')
end

2 answers

✓ Accepted answer

Use threading. You can use a coroutine or spawn, but there's use cases for both.


game.Players.PlayerAdded:wait()
local verdade = false
local applevalue = game.Workspace.appleintvalue
applevalue.Value = 0
-- wat
--applescripton = true
--[[ wat
^while applescripton == true do
..(while true do comand)
--]]

spawn(function()
	while true do 
		print ( 1 ) 
		wait(1)
	end
end)

while true do 
	print ( 2 ) 
	wait(1)
end

2 comments

0

but the loop inside the function should be repeating endlessly. Since it is inside a function, will this happen?

0

They'll both repeat endlessly unless you break out of them with 'break' or if applescripton is no longer true in your case. 

While true loops Aways needs a wait() in side on them.

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