How would I make a brick follow a certain path as if it is moving like a car?

So, I am planning to make a car that follows a certain path (around a race track) and that’s the only path. One attempt that I thought I could do was making a sort of thin invisible track which the car must follow, but wasn’t entirely sure what script I would use for that. I thought that the :MoveTo might come in use for making this, but also wasn’t entirely sure on how to use it.

If you could suggest something I could look into that might work that would be great, I’m not requesting any sort of code as I want to use this as a learning curve, thanks!

2 Likes

To add, I don’t need it to go different ways each time, I just want each car to follow an exact path on the racetrack which is the same every single time.

you could maybe turn the race car into an npc and probably use this

then change the npc walkspeed

3 Likes

Also you should have the npc movement looped, if what ur trying to achieve is to have it go around the race track.

How can I turn the car into an NPC? I want the player to sit in the car etc, so it would be a weld of different parts.

then after u have weld the different parts

use some of the scripts in this video to help u out

2 Likes

TweenService and PathFindingService should work fine

Are you trying to make the car go to a part? Using a model and welding it to a NPC will make it have some extremely sharp turns.

Extreme turns are demonstrated in this video: https://www.youtube.com/watch?v=IHSZIg3Q94M - You’ll notice that when making a U-Turn, it is an extremely sharp turn.

I created a car that essentially follows a part and finds the angle between the part and the car and drives towards it. Are you looking for something like this: AI CARS.rbxl (148.2 KB)

Note: This does not use the pathfinding service given by Roblox.

3 Likes

Sorry for bump, but having to print the target angle every time causes the game to lag extremely. I fixed the lag by removing the Print() function in your script.

Whoops, I didn’t realize I left that in there. I was just using that for testing.

You can use pathfinding to place some parts on the path which car will go. And then you should use tween service for smooth move.

Here is a example of tween:

local ts = game:GetService(“TweenService”)
local part = script.Parent
local info = TweenInfo.new(2)
local properties = {Position = —position of the part which generated in way—}

local tween = ts:Create(script.Parent,info,properties)

tween:Play()

2 Likes