Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Do you know why this code isn't running? It was working just fine a few minutes ago

local movingPart = script.Parent

local function move()

movingPart.Position = movingPart.Position + Vector3.new(0, 0, .01)

end

while true do

move()

end

I had a longer version before and it worked just fine. A few minutes later I tried to run it and it says the script has been running for a long time and then asks me to kill or break the script. I even opened up a new Place on studio and it still wants me to kill it. Do you know whats wrong?

2 comments

0

It wont let me post it the right way. Sorry.

0

Good as I can get it...

1 answer

You need to add a wait() timer for your loop, otherwise it will loop it without time in between, making it go for infinite.

local movingPart = script.Parent

local function move()
	movingPart.Position = movingPart.Position + Vector3.new(0, 0, .01)
end

while true do
	wait() --Small wait between loops
	move()
end

Also for future questions, select over the code you have and click the code block (lua symbol) to turn your text into RBX lua!

This discussion is preserved as it was. New answers, comments, and votes are closed.