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

How do I make the block travel in the direction I'm facing?

Asked by
neoG457 315 Moderation Voter
10 years ago
y.velocity = Vector3.new(0, -10, 12)

The code above makes the block travel but I want it to travel in the direction I'm facing, How would you do that?

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

In order to move a block the direction you're facing, obviously you must have some way of accessing which direction you're facing. This is done by using lookVector. lookVector is a property of CFrame that allows you to access which way an object is facing.

"The lookVector of a CFrame is a unit vector pointing in the direction of the CFrame's forward direction (-z in object space) or front face." -BlueTaslem

workspace.Part.Velocity = workspace.Part.CFrame.lookVector * 100

This will make an unanchored and unattached Part move toward its front face. We multiply it by 100 just to add some speed.

Ad

Answer this question