How to use AssemblyLinearVelocity in a specific direction

This will be a short question.

I am familiar with AssemblyLinearVelocity and how to use it, but how do I make it do it in the direction the part’s facing, and how so I then change the force amount?

I know there’s CFrame.LookVector but how would I properly use it for this?

I did look for solutions, but I only found the solutions to how to generally use it, not specifically how to set it to the part’s direction.

If you have any suggestions or solutions, you can comment down below. Thank you.

4 Likes

Velocities are Vector quantities, meaning they both have a magnitude and a direction. It’s as simple as

local speed = 50
local direction = Vector3.new(0, 1, 0) --upward facing vector
local velocity = direction * speed
1 Like

But How do I make the force go in the direction of the part’s orientation?

1 Like
local speed = 50
local direction = part.CFrame.LookVector
local velocity = direction * speed
5 Likes

Is this a LinearVelocity?TEXTLIMIT

It would work with linearvelocity. Just set the velocity property of the linearvelocity to the value of the “velocity” variable

In this case I would probably make it oversimplified, just make an attachment and a linear velocity, and rotate the attachment that way you want.

And then how do I apply this velocity?
@goldenguy9

Create an attachment in the part you want to move.
Set the Attachment0 of the linearvelocity to the new attachment.
Set the velocity of the linearvelocity using a script.

The “new attachment” is what?

Let me get this straight.

You make Attachments 0 and 1 that connect from the part to the LinearVelocity, and you then code that?

The new attachment - as in the one I instructed you to create in the first sentence of my last post.
Please read it again.

I might be stupid but I don’t understand it. I need a clearer explanation…

Inside the “Explorer” tab of your ROBLOX Studio application, you will be able to see your part.
It will look something like this:
image
Right click on the part and click “Insert object”, then pick “Attachment”
image
Repeat the same, this time choosing “LinearVelocity”.
image
Click on the LinearVelocity and go inside the “Properties” tab on Studio.
Select the “Attachment0” property, and then click the attachment in explorer.

Then, you will be able to reference the linearvelocity in a script and set the “VectorVelocity” property to what I previously instructed.

Maybe not that specific but that helped.
Thank you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.