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
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