Why is this While loop not running?

Hi, I am confused on why the bottom while loop in this script isn’t running, I don’t know what would be blocking it from running.

local textLabel = script.Parent:WaitForChild("Main"):WaitForChild("Text")
local speakerGui = script.Parent
local doyes = true
local build = true

speakerGui.Enabled = false


while true do
	wait()
	if game.Workspace:FindFirstChild("Detector") == nil and doyes == true then
		doyes = false
		speakerGui.Enabled = true
		
		local function typewrite(object,text,lenght)
			
			for i = 1,#text, 1 do
				object.Text = string.sub(text, 1, i)
				wait (lenght)
			end
		end
		
		typewrite(textLabel, "Hey there "..game.Players.LocalPlayer.Name.."!  Welcome to Build a Boat The Story Game",0.03)
		task.wait(4)
		if #game.Players:GetPlayers() > 1 then
			typewrite(textLabel, "You're group are going to start off by building a starter boat",0.03)
		else
			typewrite(textLabel, "You, the adventurer of this story, will start off by building a starter boat",0.03)
		end
		task.wait(3) 
		typewrite(textLabel, "Here are a set of blocks you can pick up. You will put them somewhere after",0.03)
		task.wait(4) 
		speakerGui.Enabled = false
		game.Workspace.Barrier:Destroy()
		
	end
end

while true do
	wait()
	print("hi")
end

Please tell me what is causing this and how to fix it, thank you

the second loop won’t run until the first one stops running.

check this out for running multiple loops at once:

1 Like

wrap the first while loop in a coroutine

1 Like