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.
local velocity = script.Parent.LinearVelocity
local target = script.Parent.Parent.Part2
while task.wait(0.1) do
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
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.
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:
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.