Task.wait stopping my script

I’m trying to make a loading screen and also a starting cutscene in one script. But in this function, the task.wait stops the whole script.
I’ve tried debugging it, nothing
i’ve tried removing it, works.

Every single task.wait in that function stops the script

local function Start ()
	print("Start() called")
	task.wait(1)

	local surfaceGui = clock:FindFirstChild("SurfaceGui")
	if not surfaceGui then
		warn("SurfaceGui not found on clock!")
		return
	end

	local text = surfaceGui:FindFirstChild("TextLabel")
	if not text then
		warn("TextLabel not found inside SurfaceGui!")
		return
	end

	local function setText(bool)
		print("Setting text. Bool =", bool)

		local success, err = pcall(function()
			sfxFolder.clock:Play()
		end)
		if not success then
			warn("Clock sound error:", err)
		end

		if bool then
			text.Text = ""
		else
			text.Text = "08:00"
		end
	end

	for i = 1, 8 do
		print("Loop iteration:", i)
		setText(true)
		task.wait(1.5)
		setText(false)
		task.wait(1.5)
	end

	print("Start() finished")
end

Sorry for the dumb question but why do you need task.wait for?

I mean yielding a thread is kinda what task.wait() is used for so im not sure what you were expecting

just to add a delay, having the cutscen start right after the loading screen finishes is kinda ugly. Also for the for loop, wich would just spam the sound

Which task.wait are you having a problem with?

literally its like i typed task.wait(inf) instead of task.wait(1). I waited a lot, like a minute and still nothing

all of them, literally all of them

Im not sure what the problem is they all wait for 1.5 seconds no?

yep, and for some reason it stops the whole script (saying again just to make you understand, its like its waiting an infinite amount of time

maybe its a bug (typing something here so i reach 30 letters)

Why cant you just use task.delay?
Edit: yes i could also be a bug

Have you tried defining all the functions outside of the Start() function

i am gonna try it ( typing something here again so i reach 30 letters)

what do you mean? like using task.wait() outside that function? because if yes, it does work

I meant the functions such as setText(), can you try defining them outside the Start function

still nothing… atp i think i’ll just scrap this project. Since this cutscene is probaly the most important one

sure, i am going to try it now

Make sure to pass the needed Instances through the function

Is that all the code inside the script?

it works when its called one time. But when you put it in a for loop with task.wait it doesnt work