Car Script Not Working

So I’m working on a script to make an advanced car in Roblox (without a vehicle seat). When the player presses W the car will accelerate (“wValue” determines whether the W key is pressed or not)

The issue is the the car doesn’t even budge when I play the game and hold W. Any recommendations to fix this script?

local wValue = nil
local maxSpeed = 50
local accelerationRate = 2
while wait(0.1) do
	wValue = game.Workspace.valueFolder.wValue.Value
	if wValue == true then
		if game.Workspace.car.LeftWheel.AngularVelocity < 1 then
			game.Workspace.car.LeftWheel.AngularVelocity = 2
			game.Workspace.car.LeftWheel1.AngularVelocity = 2
			game.Workspace.car.RightWheel.AngularVelocity = -2
			game.Workspace.car.RightWheel1.AngularVelocity = -2
		end
		game.Workspace.car.LeftWheel.AngularVelocity = tonumber(game.Workspace.car.LeftWheel.AngularVelocity)*accelerationRate
		game.Workspace.car.LeftWheel1.AngularVelocity = tonumber(game.Workspace.car.LeftWheel1.AngularVelocity)*accelerationRate
		game.Workspace.car.RightWheel.AngularVelocity = -(math.abs(tonumber(game.Workspace.car.RightWheel.AngularVelocity)*accelerationRate))
		game.Workspace.car.RightWheel1.AngularVelocity = -(math.abs(tonumber(game.Workspace.car.RightWheel1.AngularVelocity)*accelerationRate))
	end
end
2 Likes

I placed some print() statements and according to the script, the speed is constantly at 4 units of speed, yet the car still does not move

1 Like

You are applying a velocity, but there isn’t any torque, so the car won’t move.

If you are using Cylindrical constraints, make sure the AngularAcuatorType is set to Motor.
Then apply a value to it, usually the LeftWheel.MotorMaxTorque = seat.Torque.

There isn’t any complex equation to it you are just setting the MotorMaxToque to the value set in the seat, you can enter it manually but this isn’t the best option for customization down the line.