Moving an entire model from Point A to Point B

So for my game I was planning on making a Delivery Truck/Boat that would move. However, I don’t know how I would do that as it would be an entire model. Look at this picture for example:


Point A is the starting point and it takes a path (the line) to point B SMOOTHLY.

How would I do this?

1 Like

I suggest taking a look at this: Introduction to Tweening Models

1 Like

Pretty sure he’s more wanting to have a model interpolate smoothly in a certain path. Premade, I assume, in a smooth manner where CFrame interpolation (:Lerp section) and Bézier Curves comes in the picture.

What I would do for the actual moving an entire model part of the question here though. Would be that I’d weld everything to one main part in the model, then CFrame that main part only, so the other parts welded to it would naturally follow. :slight_smile:

2 Likes

I just drew a random line that was curvy for an example. I might just make it go straight.

You would need to first get a list of points that make up the line so it follows the curve that you want. Then you simply tween the model to each point in the list using tween service or whatever other method you want

Then you would still do as I said, just without the Bézier Curves.

@ZurichBT I tried your method out with a simple truck I made but then when I played the tween the truck starting to rotate 90º.

local TweenService = game:GetService("TweenService")

local Panel = workspace.Truck
local PanelRoot = Panel.PrimaryPart

wait(2)

local PanelSlideInfo = TweenInfo.new(5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0) -- Let's use all defaults here

local PanelSlideTween = TweenService:Create(PanelRoot, PanelSlideInfo, {
    CFrame = workspace.Waypoint.CFrame,
})

PanelSlideTween:Play()

And then when I added this line to my code:

Rotation = Vector3.new(0, 0, 0)

Only the PrimaryPart had rotated…

Are you sure you welded everything correctly to the PrimaryPart?

I put this code in the command bar like the tutorial said:

local Panel = workspace.Truck
-- Using Panel.PrimaryPart for convenience's sake
local Part1 = Panel.PrimaryPart

for _, Part0 in pairs(Panel:GetChildren()) do
	if Part0:IsA("BasePart") and not (Part0 == Part1) then
		local WeldConstraint = Instance.new("WeldConstraint")
		WeldConstraint.Part0 = Part0
		WeldConstraint.Part1 = Part1
		WeldConstraint.Parent = WeldConstraint.Part0
		
		Part0.Anchored = false
	end
end

Part1.Anchored = true
Part1.CanCollide = false
2 Likes

Uhh, I wouldn’t use the command bar to weld things. I personally really enjoy this welding plugin. It’s really easy, and it’ll explain how it works by hovering over the buttons.

1 Like

Still haven’t found a solution. Now the other parts are spinning while the PrimaryPart is rotating.

Then it looks like you haven’t been listening very well. I’ll show you step-by-step what you have to do:

  1. Make an invisible and anchored part that is the size of the entire model.
  2. Unanchor every other part in the model.
  3. Insert the weld script you showed earlier into the model, not any part inside the model (note: make sure it is welding to your invisible part).
  4. Test the game in studio, then copy all the contents of the model.
  5. Exit the test.
  6. Delete all the contents you have in your current model and replace it with the new ones you got from the test.
  7. Delete the weld script.
  8. Lastly, insert a script like this that will tween the invisible part:

If the model still isn’t tweening correctly, you either had not followed the steps correctly or your code isn’t working as expected.

3 Likes

Putting the weld script in the command bar is not how you do it. It has to be in the model as a physical script.

1 Like

Your truck will always try to match your waypoint’s CFrame exactly, which could be why it’s rotating. Try making it just match the waypoint’s position:

local TweenService = game:GetService("TweenService")

local Panel = workspace.Truck
local PanelRoot = Panel.PrimaryPart

wait(2)

local PanelSlideInfo = TweenInfo.new(5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0) -- Let's use all defaults here

local PanelSlideTween = TweenService:Create(PanelRoot, PanelSlideInfo, {
    CFrame = CFrame.new(workspace.Waypoint.CFrame.p) --Notice we're using the position of the CFrame and not just the whole CFrame!
})

PanelSlideTween:Play()
4 Likes

Thanks, it worked. I also used your method @ZurichBT.