Making a cargo caravan. Or at least a truck with tween

No it isn’t for gui. an example for tweenService is

local tweenService = game:GetService("TweenService")
local brick = script.Parent

local tweeningInfo =,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,1,true,0.5) -- the details of the tween

local properties = {Position =[[write desired pos here]])} -- this is where you want stuff to happen such as changing position or size or any other property of the brick.

local tween = tweenService:Create(brick,tweeningInfo,properties) -- the tween is being created hence the create


And, you cannot tween a thing with multiple parts as that would require you tweening ALL the parts or using the primary parts.
EDIT: spelling error was corrected

I have a very shallow understanding of coding, and I kind of just learned to do loops, change part properties and such. But if the truck is only moving from a single person’s screen, how would the other players interact with it? Also, what’s AlignOrientation and proxy parts?

Client sided means that itll show for the player only, so everyone will see it.

ex: if the truck in player 1 screen was moving but suddenly stopped for any unknown reason, player 2 wouldn’t see it stop as the stopped truck is CLIENT sided. player2 would only see their truck still moving.

Yes, but if it was just on the server wouldn’t the truck just behave the same for everyone? What I mean is my game has PVP so I was hoping that they could just fight on the truck while getting their loot.

Read what vastqud said. if the truck runs without issues the truck will act the same for everyone.

I understand. This kind of thing is probably hard to understand for people new to scripting, so for now you can just tween the trucks on the server and not worry about client-siding. It does help a lot with lag and how smooth the trucks are though. If you want to learn, I suggest starting with network ownership although it isn’t related to what I’m doing with my helicopter.

For tweening models, this is a good place to start: Introduction to Tweening Models

If you still want to understand how client siding would work in your case you can message me and I’d be glad to explain any questions you have.

Yeah, does that involve local scripts or normal ones? I’m not quite sure the difference, but I have a feeling it involves that. Edit: the client side things

I’ll take a look at that link seems promising.

local scripts are client sided and scripts are for the server. happy scripting!

That would make sense, I was messing around with a music script with a local version and when my character died the song restarted, but for my friend it didn’t. It’s all very new stuff to me, sorry for being a little below par when it comes to this kind of stuff.


No problem, I am still learning scripting as well. I started about 5 months ago, and paying attention and practicing really paid off.

I think I’m going to work in a separate place from my real game with tweening, and I’ll see if it works out. I’ll tell you later if it does.


I copy-pasted the code, tweaked it a little, but the “Car” doesn’t seem to want to move…

Not sure if anyone has mentioned this, but if your trick is a Model, just set the Model.PrimaryPart to a part then use something like this:

local TweenService = game:GetService("TweenService")
local checkpoints = {} -- invisible parts along the road in the workspace
local truckModel = -- path to truck model here & make sure you set the primary part property of the model
local truckPrimaryPart = truckModel.PrimaryPart

-- this creates a linear animation TweenInfo configuration taking animationTime long
function createNewTweenConfig(animationTime)
        Enum.EasingStyle.Linear, -- you could change this or add more params above

-- this drives the truck to the specified checkpointPart and it takes timeItTakes to arrive
function driveTruckToCheckpoint(checkpointPart, timeItTakes)
        createNewTweenConfig(timeItTakes), -- creates a new tween info
            CFrame = checkpointPart.CFrame

for i, checkpoint in pairs(checkpoints) do
    driveTruckToCheckpoint(checkpoints[i], 30) -- this drives the truck to every checkpoints taking 30 seconds to get to each one

1 Like

Alright, being the dumb dumb I am when it comes to coding, I’m going to try to digest it and explain what I understand… The code starts the tween service, you got some variables for the truck, and it’s root and the checkpoints (that’s helpful). Not sure what the is… and the truck tries to go to different points and there’s a set number of seconds it takes to get to each one?

I’m also confused how I could add multiple checkpoints in the little {}

The PrimaryPart of a Model is the Part whose CFrame (if it moves) moved the whole model along with it.

Also, TweenInfo is just data you give to TweenService to describe the animation. You can read more about it here:

Next, checkpoints is a table which uses curly braces like this: {}
In your game, you could add invisible parts to the workspace called something like Checkpoint1, Checkpoint2, and Checkpoint3 and put them along a road or wherever you want your truck to drive. To add them to the checkpoints table, you could write your checkpoints table like so:

local checkpoints = {workspace.Checkpoint1, workspace.Checkpoint2, workspace.Checkpoint3}

createNewTweenConfig(animationTime) is a function which takes a number as a parameter called its animationTime. It spits out or returns a TweenInfo, which is just the animation details and the TweenInfo specifies how long that animation will take to complete by assigning the first parameter of to be animationTime.

driveTruckToCheckpoint(checkpointPart, timeItTakes) takes two parameters. It takes a checkpointPart, which is just one of the parts in your checkpoints table or any part that you want. It also takes a timeItTakes which basically is how long you want the drive to take. Inside this function, we actually create the animation using TweenService:Create()
The Create function of TweenService takes your truck model, the TweenInfo returned from createNewTweenConfig(timeItTakes), and another table of properties which you want the animation to change. The :Create() function just created the animation, so I call :Play() at the end of it to actually play the animation created. TweenService:Create(...):Play() basically creates the animation of a certain length, and moves your truck to the desired checkPointPart by “tweening” the CFrame of your truck model’s PrimaryPart to the checkpoint part’s CFrame. At the end, I just wait(timeItTakes) to ensure that you wait until the animation is done before moving the truck again.

The for loop at the end of the code just goes through every checkpoint in your checkpoints table and animates your truck to each one sequentially. This means it would visit the first thing in the table, the second thing in the table, and so on. You can probably remove this, as it was just an example of calling the functions I provided.

I hope this helps you comprehend! Good luck! :slight_smile:

1 Like

Thank you! That is verrrry helpful. This will add a lot of depth in my game.

robloxapp-20200428-1155057.wmv (317.9 KB)

I think the hotdog forgot it shell. is it because it should be unanchored? also do I just turn the check points to make it turn?

You should make the checkpoints anchored, floating parts. For the truck, it does not have to be anchored. You can unanchor the PrimaryPart and weld it to the other parts in the truck so that even though it’s unanchored, it stays in its position and only moves when you change the CFrame of the PrimaryPart.

Thank you. I’ll tell you this: you made my life much easier, once again thanks!

robloxapp-20200428-2141207.wmv (1.4 MB)

I made a model for the script. I think it’s nice. Appreciate everyone’s help.