Moving Blocks

Creating Blocks

First, create a Model. Right click, Insert Object, and Find Model. The icon looks like this.

Name it “Blocks.”

Create 3 Parts. Name them MovingBlock, StartBlock, and FinishBlock. Drag them into the model Blocks. Color them like I did to keep track of which is which.

Move the Blocks up into the air and Anchor them.

Position & Script

First, hit the + next to the MovingBlock and add a BodyPosition. It has a Rocket icon. Add a Script into the ServerScriptStorage.

We will start off by writing out our variables.

Then create the code that moves it back and forth. We use a while loop, which works like a forever loop because true is always true.

TEST IT! You will see it hits the blocks and spins around. We need to fix a few things. 

For StartBlock and FinishBlock, anchor them but uncheck CanCollide (that’s in Properties near Anchored). DO NOT anchor the MovingBlock but do keep CanCollide Checked.

Add BodyGyro to MovingBlock and set all the numbers to 400,000.

If you don’t stay on the block when it moves, scale the blocks a little bigger.

The moving platform doesn’t stay up with Start or Finish so add to the Maxforce of Y and make it 40,000.

That should be enough to make it work!