local Brick = script.Parent function MoverTest() game.Workspace.Brick.Position = Vector3.new(-100.5, 80, 231) wait(0.5) game.Workspace.Brick.Position = Vector3.new(-100.5, 90, 231) wait(0.5) game.Workspace.Brick.Position = Vector3.new(-100.5, 100, 231) wait(0.5) end MoverTest() repeat until MoverTest() ~= nil
Wow you're getting a lot better! :D
I'm assuming you're trying to move the brick up 10 studs every time the loop runs. You're really close but you need to create a variable and put the variable into the Y position.
Also, script.Parent
is referencing the Brick, you can just use the variable "Brick" instead of going through game.Workspace.Brick
every single time.
local Brick = script.Parent local yPos = 80 local function MoverTest() Brick.Position = Vector3.new(-100.5, yPos, 231) yPos = yPos + 10 wait(0.5) end repeat MoverTest() until yPos == 70
We're creating a variable called 'yPos' that we are going to add 10 to every time it repeats. In the function MoverTest()
, we are setting the brick's position to yPos, which is 80, then adding 10 to yPos.
This means next time we use yPos it will be 90, then 100, then 110... and it will run forever... until yPos == 70
. Of course we know yPos is never going to equal 70, so it's going to do this forever... until you stop the game :P
(also the wait is there so the game doesn't crash by looping a bunch of times)