Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
CVDev 2
6 years ago
Edited 6 years 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?

0
It wont let me post it the right way. Sorry. CVDev 2 — 6y
0
Good as I can get it... CVDev 2 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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!

Ad

Answer this question