So I made a car, but i'm trying to steer it in a direction. When I tried it, it sent the car straight into the middle of the map. Can you help? anyways here is part of the code. (no stealing ^^)
if key == "a" and vehicleseat.Occupant == player.Character.Humanoid then local l1 = workspace.Car:WaitForChild("Left1") canOff = true repeat l1.CFrame = CFrame.fromEulerAnglesXYZ(workspace.Car.PrimaryPart.Position.X,workspace.Car.PrimaryPart.Position.Y + 0.5,workspace.Car.PrimaryPart.Position.Z) r1.CFrame = CFrame.fromEulerAnglesXYZ(workspace.Car.PrimaryPart.Position.X,workspace.Car.PrimaryPart.Position.Y + 0.5,workspace.Car.PrimaryPart.Position.Z) wait(0.01) until canOff == false or vehicleseat.Occupant == nil end
CFrame.fromEulerAnglesXYZ
creates a new CFrame with no positional components, only rotational. This is why your car goes to the middle of the map, since you're setting the part CFrame to a CFrame with no positional components, the position of your parts go to the coordinates (0, 0, 0) which is at the center of the map.
Moreover, you're using CFrame.fromEulerAnglesXYZ
incorrectly. CFrame.fromEulerAnglesXYZ
takes in 3 arguments which are the angles in radians that you want the part to rotate in.
Here's an example of correct usage:
part.CFrame = part.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(10), 0)
This will rotate part
in the y axis by 10 degrees
Here's a link from the wiki on how to understand CFrames: https://developer.roblox.com/en-us/articles/Understanding-CFrame