It is running the loops successfully but the parts' position in the workspace is not changing.
detector = script.Parent gate = game.Workspace.Gate open = false position = gate.Position.Y detector.MouseClick:Connect(function() if open == false then detector.MaxActivationDistance = 0 for i = 1,17 do print("moved") position = position + 1 wait(0.5) end detector.MaxActivationDistance = 15 open = true else detector.MaxActivationDistance = 0 for i = 1,17 do position = position - 1 wait(0.5) end open = false detector.MaxActivationDistance = 15 end end)
Try using Vector3 to change the part's position. Here's my code:
detector = script.Parent gate = game.Workspace.Gate open = false detector.MouseClick:Connect(function() if open == false then detector.MaxActivationDistance = 0 for i = 1,17 do print("moved") gate.Position = gate.Position + Vector3.new(0, 1, 0) wait(0.5) end detector.MaxActivationDistance = 15 open = true else detector.MaxActivationDistance = 0 for i = 1,17 do gate.Position = gate.Position + Vector3.new(0, -1, 0) wait(0.5) end open = false detector.MaxActivationDistance = 15 end end)