Looping sentence being interrupted

hello! so
I made a part that if you touch it, it does stuff, and as you can see,

In this sentence, I made a while blur.Size < 56 do and It’s like a cutscene, I made it increase the blur size in the lighting, but there’s no way for me to add another wait(5) for example and add more stuff like this inside that sentence, otherwise it will include it as the “while blur.Size <56 do” sentence and will bug the waittime out.

this is the script, let me know if i didn’t explain correctly.
Help is appreciated!

local debounce = false

local blur = game.Lighting.Blur

script.Parent.Touched:Connect(function()

if not debounce then

debounce = true

workspace.Failed:Play()

door.Disabled = false

wait(3.5)

door.Disabled = true

wait(7)

workspace.Failed:Stop()

workspace.SFX.Whispers:Play()

workspace.SFX.Heartbeat:Play()

workspace.SFX.HeavyBreathe:Play()

wait(5)

while blur.Size < 56 do 

blur.Size = blur.Size + 1
--If I'd put stuff here, it will include it as this sentence but i want it to make it work separately.
    wait()

end

end

end)

Try coroutines. Similar with spawn, it runs on a different thread so it won’t interrupt the script.

Try making your code asynchronous with coroutines!

local debounce = false

local blur = game.Lighting.Blur

script.Parent.Touched:Connect(function()

if not debounce then

debounce = true

workspace.Failed:Play()

door.Disabled = false

wait(3.5)

door.Disabled = true

wait(7)

workspace.Failed:Stop()

workspace.SFX.Whispers:Play()

workspace.SFX.Heartbeat:Play()

workspace.SFX.HeavyBreathe:Play()

wait(5)

blurify = coroutine.wrap(function()
while blur.Size < 56 do 

blur.Size = blur.Size + 1
--If I'd put stuff here, it will include it as this sentence but i want it to make it work separately.
    wait()

end)
blurify()
end

end)