I'm trying to make a script which when the brick is clicked it moves, although I don't know how to connect
while true do
script.Parent.Position = script.Parent.Position + Vector3.new(0,0,0.1)
wait(0.1)
end
script.Parent.ClickDetector.mouseClick:connect()-- I don't know what to put here.
In the () I normally put the name of the function I need to call. But when I use a how do I call the script?
Then I tried to do this
function move()
script.Parent.Position = script.Parent.Position + Vector3.new(0,0,0.1)
wait(0.1)
end
script.Parent.ClickDetector.mouseClick:connect(move)
But then it only moved once each time I clicked, but I'm not sure if you can put a while true do in a function?

3 comments
You most definitely can put a while loop inside a function, and anything else for that matter -- even other functions :)
Oh, thanks.
Be aware that if it's "while true do", your script will only exit the loop if you have a break statement inside it that executes.