Moving a model forward using Vector3

Hello, I am trying to move a model, so I welded every other par in the model to the body. Even I welded every other part to the body, only the body moves. I want to make everything move in the model, how can I achieve this? Thank you.

Here is my script (It’s located in the model, and it’s a Script):

local car = script.Parent.Body

car.Vector3.new(10, 0, 0)
2 Likes

I’m not really sure what you’re trying to do here? You set the property of the car like you normally would?

car.Velocity = Vector3.new(10, 0, 0)
1 Like

I was trying to move the car forward using Vector3. Also, I’m not good at scripting.

Edit: Oops, I got confused with the script that I watched in YouTube to make a conveyor belt. :sweat_smile:

Add an invisible part in the centre of the car and rename it to ‘Primary’. Then go to the model, click primary part and set it to the part called, ‘Primary’. Then simply do this in your script:

local car = script.Parent
car:SetPrimaryPartCFrame(car:GetPrimaryPartCFrame() * Vector3.new(10,0,0))
2 Likes

Thanks, I can’t test it right now, so I will test it out when I can, and tell you the results. :grinning:

There is an error when I tested it out:
error10
What am I doing wrong? Also I put the script in the model of the car, not the “Primary Part”. Thanks.

local car = script.Parent
car:SetPrimaryPartCFrame(car:GetPrimaryPartCFrame() * CFrame.new(10,0,0))

try

3 Likes

Thanks, it works, but it doesn’t work the way that I want. I want the car to actually slide to the position, not teleport to the position.

There are two type of postion storage(ways to change and make positions for parts).

CFrame and Vector3. Vector3 is not compatiable with CFrame directly like adding it. CFrames hold position and rotation.

You can add Vector3s by doing(example) Vector3.new(10,0,0) + Vector3.new(4,0,0)

You can add(like change by amount) CFrame by multiplying the two cframes. CFrame.new(10,0,0) * CFrame.new(4,0,0)

1 Like

So do you mean if I use CFrames, the car will teleport to the position?

1 Like
function slideTo(obj,goalVector)
	local sP = obj:GetPrimaryPartCFrame()
	for i = 0, 1.01, 0.01 do
		print(i)
		obj:SetPrimaryPartCFrame(sP:Lerp(CFrame.new(goalVector),i))
		wait(0.03) -- change number, smaller the faster. limit is 0.03
	end
end
slideTo(script.Parent, Vector3.new(100,0,0)) -- run for smooth.
2 Likes

Oh… Thanks, I didn’t expect a full script… Is it ok to use this script if it works? Do you want credit for it?

Also, I have a question, what does “Lerp” do? I never heard about it. :grinning:

When I tested the script, the car goes down, and left.

Lerp, I think it’s basically a linear animation for me

1 Like