Making 2 parts go toward each other

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    the 2 parts to go towards each other
  2. What is the issue? Include screenshots / videos if possible!
    idk how to do this
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    tween and that
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Part1 = script.Parent.Helicopter1
local Part2 = script.Parent.Helicopter2
Part1.CFrame = CFrame.lookAt(Part1.Position, Part2.Position)
Part2.CFrame = CFrame.lookAt(Part2.Position, Part1.Position)

i need the 2 helecopters to meet at the middle of the map
ATM they only face each other

Thanks for any help!!! im sorry i feel so stupid right now… i can do stuff way more complex than this

Never mind i fixed it with Lerp

Hey there. You’re gonna need to get the vector between the 2 parts. Each part will basically calculate the direction towards the other part.

An example would be:

local Part1 = script.Parent.Helicopter1
local Part2 = script.Parent.Helicopter2

local vectorFromPart2ToPart1 = Part1.Position - Part2.Position -- Vector from part 2 to part 1
local vectorDirectionFromPart2ToPart1 = vectorFromPart2ToPart1.Unit -- Unit vector (aka normalized vector.) This means the vector has a length of 1. You can multiply by any speed scalar you want
local moveToPositionDirection = vectorDirectionFromPart2ToPart1 * moveSpeed -- Basically 1 * moveSpeed

-- You'll want to update the part's location every frame. You can achieve this with a while loop
while task.wait() do
    Part2.CFrame = Part2.CFrame + moveToPositionDirection
end

Of course, this also depends on how you want to update the position of each object

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