Script timeout; Exhausted allowed execution time

I was looking at other threads covering this issue and I just can’t wrap my head around how i’d fix it in my case, here’s the code, the error happens at the while loop

local ws = game.Workspace

local p1 = ws.Roboscrub1

local p2 = ws.Roboscrub2

local p3 = ws.Roboscrub3

local p4 = ws.Roboscrub4

local p5 = ws.Roboscrub5

local p6 = ws.Roboscrub6

local clickDetector = p6.ClickDetector

local click2 = p5.ClickDetector

local click3 = p4.ClickDetector

local click4 = p3.ClickDetector

local click5 = p2.ClickDetector

local click6 = p1.ClickDetector

local head = ws.Chars["Robo-ScrubAssembly"].Head

local torso = ws.Chars["Robo-ScrubAssembly"].Torso

local larm = ws.Chars["Robo-ScrubAssembly"]["Left Arm"]

local lleg = ws.Chars["Robo-ScrubAssembly"]["Left Leg"]

local rarm = ws.Chars["Robo-ScrubAssembly"]["Right Arm"]

local rleg = ws.Chars["Robo-ScrubAssembly"]["Right Leg"]

local children = ws.Chars["Robo-ScrubAssembly"]:GetChildren()

local parts = {head, torso, larm, lleg, rarm, rleg}

local descendants = game.Workspace.erimhouse.MicrowaveDoor.Door:GetDescendants()

function onMouseClick()

p6.Transparency = 1

ws.Chars["Robo-ScrubAssembly"].Head.Transparency = 0

p6.SHINE:Play()

for index, descendant in pairs(descendants) do

if descendant:IsA("Texture") then

descendant:Destroy()

end

end

end

function onMouseClick2()

p5.Transparency = 1

ws.Chars["Robo-ScrubAssembly"]["Left Arm"].Transparency = 0

p5.SHINE:Play()

for index, descendant in pairs(descendants) do

if descendant:IsA("Texture") then

descendant:Destroy()

end

end

end

function onMouseClick3()

p4.Transparency = 1

ws.Chars["Robo-ScrubAssembly"]["Left Leg"].Transparency = 0

p4.SHINE:Play()

for index, descendant in pairs(descendants) do

if descendant:IsA("Texture") then

descendant:Destroy()

end

end

end

function onMouseClick4()

p3 .Transparency = 1

ws.Chars["Robo-ScrubAssembly"]["Right Arm"].Transparency = 0

p3.SHINE:Play()

for index, descendant in pairs(descendants) do

if descendant:IsA("Texture") then

descendant:Destroy()

end

end

end

function onMouseClick5()

p2 .Transparency = 1

ws.Chars["Robo-ScrubAssembly"]["Right Leg"].Transparency = 0

p2.SHINE:Play()

for index, descendant in pairs(descendants) do

if descendant:IsA("Texture") then

descendant:Destroy()

end

end

end

function onMouseClick6()

p1 .Transparency = 1

ws.Chars["Robo-ScrubAssembly"]["Torso"].Transparency = 0

p1.SHINE:Play()

for index, descendant in pairs(descendants) do

if descendant:IsA("Texture") then

descendant:Destroy()

end

end

end

while true do

if parts.Transparency == 0 then

ws.Chars["Robo-ScrubAssembly"]:Destroy()

game.ServerStorage.RoboScrub["Robo-Scrub"].Parent = ws.Chars

ws.Lethal.CFrame = CFrame.new(0.286, 0.895, -162.564)

end

end

clickDetector.MouseClick:connect(onMouseClick)

click2.MouseClick:connect(onMouseClick2)

click3.MouseClick:connect(onMouseClick3)

click4.MouseClick:connect(onMouseClick4)

click5.MouseClick:connect(onMouseClick5)

click6.MouseClick:connect(onMouseClick6)

You have a while true do, but you do not have a task.wait()

where abouts in the loop should i put that?

while true do

if parts.Transparency == 0 then

ws.Chars["Robo-ScrubAssembly"]:Destroy()

game.ServerStorage.RoboScrub["Robo-Scrub"].Parent = ws.Chars

ws.Lethal.CFrame = CFrame.new(0.286, 0.895, -162.564)

task.wait()

end

it’s giving me the same error still

how would i put together this for loop? I’ve been trying to for a few minutes now

Since the provided solution was deleted by the author for some reason, here’s what the solution was for anyone viewing this thread in the future: