How Would I Get This Car To Move Straight?

I am trying to get this car to go straight then as soon as it reaches the end teleport back to the start any ideas on how this could be done?
image

1 Like

Use a tween. Set an end point and when it is finished, loop back again and set the car’s position to the start.

How would I use a tween sorry for asking this I usually only use parts and welds.

It has some example scripts on the page. In your case, I modified an example one.

local TweenService = game:GetService("TweenService")
local model = yourModelHere

local goal = {}
goal.Position = -- any valid vector3 position, or a CFrame position
 
local tweenInfo = TweenInfo.new(5) -- There is more data you can check out
 
local tween = TweenService:Create(part, tweenInfo, goal)

while wait(5) do 
 -- Set the model's location back to start.
 tween:Play()
end

1 Like

Not really a scripter so I dont know do I put it in a local script module script or script

You put it in a server script for everyone to see it happen, and you put it in a local script for only 1 person to see it happen.

So in your case, put it in a script (Sever script).

I tried it and it showed a red line under local


The code has a red line what does that mean

You haven’t set the goal position and the path to the model. (also the goal needs to be set.)

If I put drive straight will it drive straight?

You have to make a vector3 position for

goal.Position = Vector3.new(1,1,1) -- or whatever the position is.

1 Like

By setting the path the the “model” that you’re tweeting I mean:

local model = game.Workspace.ModelNameHere -- change model name here to the model you plan to tween

Do I keep the script in the workspace or do I put it in the model
I am sorry if I am causing you stress cause of my dumb brain.

It doesn’t matter, you could put it in workspace or the model, or in ServerScriptService.

1 Like

Now its showing little orange lines I have no Idea what I did wrong.

Show me, I could probably fix it.

Yes, where is your script and model located?


In the workspace.

Hmm, without making things to complicated for you, can you union the whole car instead of a model?