local function OnCameraUpt() if activeCar and activeCar.PrimaryPart then if…
- User
local function OnCameraUpt() if activeCar and activeCar.PrimaryPart then if activeCar:IsA("Model") and activeCar.PrimaryPart then local currentCarCFrame = activeCar.PrimaryPart.CFrame local carPosition = currentCarCFrame.Position
local x, cameraYawRad, z = currentCamera.CFrame:ToOrientation() local newCarCFrame = CFrame.new(carPosition) * CFrame.Angles(0, cameraYawRad + math.rad(-90), 0) activeCar:PivotTo(newCarCFrame) end endend
find a way for me to make the car face the camera direction with out ruining its positional movement
Assistant
To make the car face the camera's direction without affecting its positional movement, you need to adjust only the car's yaw (rotation around the Y-axis) while preserving its current position. Here's an improved version of your
OnCameraUpt()function:local function OnCameraUpt() if activeCar and activeCar.PrimaryPart then if activeCar:IsA("Model") and activeCar.PrimaryPart then -- Get the car's current position and orientation local currentCarCFrame = activeCar.PrimaryPart.CFrame local carPosition = currentCarCFrame.Position local _, currentCarYaw, _ = currentCarCFrame:ToOrientation() -- Get the camera's yaw (rotation around Y-axis) local _, cameraYawRad, _ = currentCamera.CFrame:ToOrientation() -- Create a new CFrame that: -- 1. Keeps the car's original position -- 2. Uses the camera's yaw (with -90 degree offset if needed) -- 3. Preserves the car's original pitch and roll local newCarCFrame = CFrame.new(carPosition) * CFrame.Angles(0, cameraYawRad + math.rad(-90), 0) -- Apply the new orientation while maintaining position activeCar:PivotTo(newCarCFrame) end end endKey Improvements:
- Position Preservation: The car's position (
carPosition) is explicitly preserved. - Yaw-Only Rotation: Only the yaw (Y-axis rotation) is taken from the camera, with your -90 degree offset.
- Clean Orientation: The car's pitch and roll remain unchanged (set to 0 in this case).
If You Want to Preserve Existing Pitch/Roll:
If you want to keep the car's current pitch and roll (not just position), modify the code like this:
local currentCarCFrame = activeCar.PrimaryPart.CFrame local carPosition = currentCarCFrame.Position local carPitch, _, carRoll = currentCarCFrame:ToOrientation() -- Get current pitch/roll local _, cameraYawRad, _ = currentCamera.CFrame:ToOrientation() -- Apply camera yaw but keep original pitch/roll local newCarCFrame = CFrame.new(carPosition) * CFrame.Angles(carPitch, cameraYawRad + math.rad(-90), carRoll)This way, the car will:
- Face the camera's direction (with your -90° offset)
- Keep its current position
- Maintain its existing pitch and roll (if any)
Let me know if you need further adjustments!
- Position Preservation: The car's position (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.