Exercise 5.2 – falling block
In this exercise, we will create a simple part that we will position in the air. Instead of letting physics do the work of making the block fall down, we will use tweens to make this block fall. Once the Tween is done, we will position the part back to its original position and create another tween. Throughout this exercise, we will use different EasingStyles, as explained in the Understanding TweenInfo section. This will give each fall a different effect:
Exercise:
First, we will start by setting up the part that we will create a tween for:
- Create a new part in the Workspace service. Give this part the following properties:
- Name:
TweenPart
- Size:
{5, 5, 5}
- Position:
{0, 2.5, 0}
- Anchored
: true
- Name:
Now that we have our TweenPart, let us start creating the tweens.
- Create a new LocalScript in StarterPlayerScripts.
- In our LocalScript, create the following global variables:
targetPosition
:Vector3.new(0, 2.5, 0)
startPosition
:Vector3...