How to make a part go on a predefined path with parts

Hey guys,

I am wondering how to make a system where a model, like a bus or a car goes along a predetermined path. I have a slight idea of how to do this with LinearVelocity and orientation fixing. I just need assistance with the math and a quick bug fixing.

Below, I’ve attached a video of what happened when I ran the script.

I want the bus to go along the green path without any troubles.

wait(1) -- Removes attachment to modify the bus position and orientation
script.Parent.Sensors.SpawnPos.LinearVelocity.Attachment0 =         
script.Parent.Sensors.SpawnPos.Attachment

wait(1) -- Positioning the vehicle to the spawner
script.Parent.Sensors.SpawnPos.LinearVelocity.MaxForce = 10000000272564224
script.Parent.Sensors.SpawnPos.LinearVelocity.VectorVelocity = Vector3.new(30,0,0)

-- When it touches a path part it initializes what happens.
script.Parent.Sensors.CollisionBox.Touched:Connect(function(h)
	if h.Parent.Name == "Path" then
	script.Parent.Sensors.SpawnPos.LinearVelocity.Attachment0 = nil
	script.Parent.PrimaryPart.Orientation = h.Orientation
	local direction = (script.Parent.Sensors.SpawnPos.Position - h.Position).unit
	direction = Vector3.new(-direction.x, 0, -direction.z)
	script.Parent.Sensors.SpawnPos.LinearVelocity.VectorVelocity = direction * 30
	script.Parent.Sensors.SpawnPos.LinearVelocity.Attachment0 = 
script.Parent.Sensors.SpawnPos.Attachment
end
end)

I was scrolling on the devforum to see any other solutions but I could not find any. I appreciate if you could assist me.

Thank you


1 Like

Not really a solution but I have a great module that can help you out here:

Thank you! I will check it out

Thank you Exactly what I was looking for

1 Like

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