# LinearVelocity help

Hey Devs,

I am trying to achieve a way to make a part get to a desired location with LinearVelocity. Unfortunately I haven’t been able to do that. I searched all over youtube, and devforum yet I couldn’t find anything. Here is what I have tried to do

``````local velocity = script.Parent.LinearVelocity
local target = script.Parent.Parent.Part2

velocity.VectorVelocity = Vector3.new(target.CFrame.X, target.CFrame.Y, target.CFrame.Z)
``````

I really need a quick tutorial on LinearVelocity if possible too. Thank you.

3 Likes
``````local velocity = script.Parent.LinearVelocity
local target = script.Parent.Parent.Part2

local offset = (target.Position - script.Parent.Position) --This is a vector from `script.Parent.Position` to `target.Position`

if offset.Magnitude < 0.2 then
velocity.VectorVelocity = Vector3.new(0,0,0)
else
velocity.VectorVelocity = offset.Unit * 4 -- will move '4' studs per second
end
end
``````
4 Likes

Theres a video on using the constraint here:

However it doesnt include the scripting… in your script you dont need to set the position of the attachment as the velocity force, just set a velocity force like this:

``````velocity.VectorVelocity = Vector3.new(10,0,0)
``````

It will move the part that has the linearvocity in it to the part2, your attachment.

Make sure to set the attachments correctly in the properties and also make sure that there is enough force to push the weight of your part or set your part to a lower density. Try this first with small basic blocks to see how it works.

2 Likes

Thank you, but my issue is making the part go up to its height

Thank you, I have watched that video already, I learned a little and i feel like there is much more to know.

1 Like

Decrease the density of the part that has to travel, or increase its velocity…and if it has to travel on the y axis then add that into the velocity in the y axis:

``````Vector3.new(0,10,0)
``````

Wouldn’t it just increase the speed?

Yes but since the part has weight it will counteract the speed initially.

Edit: change your part density under custom physical properties to 0.2 and see how it changes the movement.

That should remove the weight right?

1 Like

Correct… this is a quick easy way to check. But when you have more complex models you want to be careful which parts u set to massless.

It still isn’t moving up into the air like its supposed to

``````i = 0

while wait() do
i = i + 0.01
script.Parent.LinearVelocity.VectorVelocity = Vector3.new(10, 0 + i, 0)
end
``````

0.01 might be too small of an increment… does a set number work? Because it will keep moving towards the attachment if you just set a constant there.

No, it just moves in a straight line.

It works for me in testing:

Edit: the attachment can be placed anywhere, it does not have to be in another part… but in my video my attachment is where the part anchored in the sky is. You can place the attachment anywhere, it doesnt need another part.

1 Like

You can set an offset force to lift the part up. The force that counteracts gravity is `BasePart:GetMass()*workspace.Gravity`.

1 Like