In my game I have a huge door with a button you press, when you press it the door goes into the air, but doesn't stop. The way the door is set up is like this: workspace: Model: Button: ClickDetector, Script, ColorScript, MoveScript, Door: DoorScript
In the move script this is what I have wrote:
function myfunction()
local brick= script.Parent.Parent.Door
while wait(0) do
for I=1,20 do
brick.CFrame=brick.CFrame+Vector3.new(0,0.3,0)
wait()
end
end
end
script.Parent.ClickDetector.MouseClick:connect(myfunction)

2 comments
Please can you put it into the code blocks so it's easier to read.
I'm like 99% sure your problem is that you are looping forever by doing "while wait(0) do". I would just do the for loop on it's own and that should work.