While true do loop isn't working

im trying to make a while true do loop for a door to go up, but it wont work
it displays this error message

i couldn’t find any solution, also the script is this

local counter = 0

local counter2 = 0

door1 = game.Workspace.Door

local ClickDetector = script.Parent.ClickDetector

ClickDetector.MouseClick:Connect(function(PlayerWhoClicked)

while counter < 8 do

wait(0.1)

door1.Position = door1.Position + Vector3.new(0,1,0)

counter = counter + 1

end

You are missing an “end)” to the ClickDetector function. Will show you below what was missing

local counter = 0
local counter2 = 0
door1 = game.Workspace.Door
local ClickDetector = script.Parent.ClickDetector

ClickDetector.MouseClick:Connect(function(PlayerWhoClicked)
while counter < 8 do
wait(0.1)
door1.Position = door1.Position + Vector3.new(0,1,0)
counter = counter + 1
end
end) – (Add this to end clickdetector)

2 Likes

You need an extra end) to close the MouseClick script signal.

1 Like
local counter = 0
local counter2 = 0
door1 = workspace.Door
local clickDetector = script.Parent.ClickDetector
clickDetector.MouseClick:Connect(function(plrWhoClicked)
while counter < 8 do

wait(0.1)

door1.Position = door1.Position + Vector3.new(0,1,0)

counter = counter + 1

end
end)
1 Like