Car wheels turning the wrong way (via body gyro and cframes)

so i stole DemonDarble’s car script (for educational purposes, the cars were used in the old racing starter place) to modify the roblox jeep. i ported everything perfectly until the wheels turning were wonky.


the car


the jeep

they work but visually turn the wrong way. i’m going for the regretervator style of jeep from that one floor

i think it MIGHT have to do with the cframe rotation in this part of the script

local function UpdateThruster(thruster)
	-- Raycasting
	local hit, position = Raycast.new(thruster.Position, thruster.CFrame:vectorToWorldSpace(Vector3.new(0, -1, 0)) * stats.Height.Value) --game.Workspace:FindPartOnRay(ray, car)
	local thrusterHeight = (position - thruster.Position).magnitude

	-- Wheel
	local wheelWeld = thruster:FindFirstChild("WheelWeld")
	wheelWeld.C0 = CFrame.new(0, -math.min(thrusterHeight, stats.Height.Value * 0.8) + (wheelWeld.Part1.Size.Y / 2), 0)
	-- Wheel turning
	local offset = car.Chassis.CFrame:inverse() * thruster.CFrame
	local speed = car.Chassis.CFrame:vectorToObjectSpace(car.Chassis.Velocity)
	if offset.Z < 0 then
		local direction = 1
		if speed.Z > 0 then
			direction = -1
		end
		wheelWeld.C0 = wheelWeld.C0 * CFrame.Angles(0, (car.Chassis.RotVelocity.Y / 2) * direction, 0)
	end
end

this is the thruster (wheels) script

	while true do
		game:GetService("RunService").Stepped:wait()
		for i, part in pairs(car:GetChildren()) do
			if part.Name == "Thruster" then
				UpdateThruster(part)
			end
		end
		if car.DriveSeat.Occupant then
			local ratio = car.DriveSeat.Velocity.magnitude / stats.Speed.Value
			bodyPosition.MaxForce = Vector3.new()
			bodyGyro.MaxTorque = Vector3.new()
		else
			local hit, position, normal = Raycast.new(car.Chassis.Position, car.Chassis.CFrame:vectorToWorldSpace(Vector3.new(0, -1, 0)) * stats.Height.Value)
			if hit and hit.CanCollide then
				bodyPosition.MaxForce = Vector3.new(mass / 5, math.huge, mass / 5)
				bodyPosition.Position = (CFrame.new(position, position + normal) * CFrame.new(0, 0, -stats.Height.Value + 0.5)).p
				bodyGyro.MaxTorque = Vector3.new(math.huge, 0, math.huge)
				bodyGyro.CFrame = CFrame.new(position, position + normal) * CFrame.Angles(-math.pi/2, 0, 0)
			else
				bodyPosition.MaxForce = Vector3.new()
				bodyGyro.MaxTorque = Vector3.new()
			end
		end
	end

and this is the wheel position script

The first script deals with just the rotation of all 4 wheels wheel.Weld, not the steering.

The second deals with the movement of the vehicle.

You need to find the section of the script that deals with steering inputs.

I’m wondering if you’ve turned the vehicle around when you put the seat into it. Check to see if the wheels have different names for the front and back ones. If so then just rename the front wheels the back wheel name and vice versa.

1 Like

i literally did all of that except for the script checking

i have no clue what alien language he used by the cframe isn’t accurate, driver seat is 0 rotation


it’s probably this fragment, if this is the direction then turn, i tested it before, but what do the numbers mean?

wheelWeld is the axle spin of the wheels because it’s not dealing with just 2 of them, it deals with all of them.
Are all 4 wheels or wheel models, or their children named differently between the front wheels and the rear wheels?
I don’t think you’re looking at the correct section of code. Try looking for the left and right inputs in the script that tell the steering what to do, then follow that code through.

the wheels are unions and all of them are the same size. orin at at 0.0.0 as i said and changing any part of the code makes the wheels wonky.

FrontWheel and BackWheel, with Right and Left is how i named them

nothing works and i have no clue why

But how does the SCRIPT that steers them change the angle? I can’t see anywhere in the scripts you’ve provided that sets the steering angle of the front wheels.

Read my previous post. You need to find the section of code that gets the player inputs that steer the car. It may be in another script hidden somewhere else in the model.

Strange, I tested the Roblox Jeep in Studio. The rear wheels don’t spin at all while driving because the Weld takes over from the WheelWeld just in the rear wheels which makes the WheelWeld inactive…

If you look at the car you’ll see the CarScript and in that is a LocalCarScript and the RaycastModule.

The CarScript has the steering components in lines 123 to 133:

	if offset.Z > 0 then
		local direction = 1
		if speed.Z > 0 then
			direction = -1
		end
		wheelWeld.C0 = wheelWeld.C0 * CFrame.Angles(0, (car.Chassis.RotVelocity.Y / 2) * direction, 0)
	end

I played with it it seems you may have switched the Thrusters from the front to the rear wheels.
Look in the original Jeep at the Thruster in either of the 2 front wheels. You’ll see the WheelWeld is Enabled and Active, but if you click on the WheelWeld in the either of the rear wheels the WheelWeld is Enabled, but not Active. Check to see if that’s what you’ve got happening in your car.

1 Like

nothing works
it’s only the visual turning that’s the problem and i can’t get it to work even with my aster scripter friend

whatarewomentobeginwith.rbxm (34.9 KB)
why don’t YOU take a look at the model

You’ve got your Chassis Part turned 180 degrees around compared to the original Jeep. The script is checking for the CFrame offset values to see where the Thrusters are located in relation to the Chassis.

I selected the Chassis, Thrusters (4) and all 4 wheels, then rotated them 180 degrees which put the steering wheels at the front and the non-steering wheels at the back.
Because that broke all the welds to the other Parts I selected each one then used a WeldConstraint to the Chassis to reattach them.
whatarewomentobeginwith.rbxm (35.4 KB)

1 Like

THATS LITERALLY WHAT I DID ONCE
guh, thanks for helping tho the jeep works great
i think weld constraints i should use more, i know a script that auto welds them

i’ll message you if roblox breaks the jeep again

Your welcome!
You have to be careful with auto weld scripts since they can create welds between parts in a model that are supposed to move.

1 Like