How Would You Move A Part Based On Rotation?

Hello, I am pretty new to Roblox Studio, I have some basic knowledge in scripting, such as moving parts/models and creating new ones, variables, etc.

Recently I have been trying to make a game, and I have a map and everything, but what I am having trouble with is the cars.
I have been trying to make some cars that drive automatically, the goal for the coding isn’t that complex: get the rotation and move the car forward.

This is similar to moving a rotated object in the studio, you rotate the object and move it by the rotation axis, as shown in the picture below.

However, I have been unable to find a solution. I have looked on the forum, but everything I found was either not what I was looking for or was too complex to understand. Copy and pasting has not worked either as there has been an error.

Any help would be appreciated! :grinning_face_with_smiling_eyes:

2 Likes

Are the cars your trying to make supposed to be utilised by players, or are they just for the background and attention to detail?

You can use the LookVector method of the Objects CFrame property. You can check out these sources:

I dont have time to write.

while true do
wait()
workspace.Part.CFrame = workspace.Part.CFrame + workspace.Part.CFrame.LookVector * 2
end
9 Likes

I copy and pasted the script, and it worked! Thank you for taking the time to type the script :slight_smile:

1 Like

Thank you! I found somthing similar to this, but when I tried the code it would only go left and right.

They were just for the background, unless you run into one which would kill you (Like the cars from Be Dead Forever Simulator)

Anyway, maybe in the future ill add cars you can drive, but the whole point of the game is to test my coding.
It already got solved anyways, but thanks for being so quick to respond!

(I replied to everyone bc I thought it was nice, sorry if it looks spammy.)

Ye there are different Vector methods regarding the CFrame property, e.g RightVector, LookVector and UpVector

1 Like