Why won't my car move?

I am currently trying to make a car move. However, the car doesn’t seem to be moving at all. I am using BodyThrust and BodyAngularVelocity to help move the car, and it just doesn’t move whatsoever. I tried using a remote event to make the server move the car, but that didn’t work either. What am I doing wrong with BodyThrust and BodyAngularVelocity?

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local ContextActionService = game:GetService("ContextActionService")
local runService = game:GetService("RunService")
local moveCar = game.ReplicatedStorage.Remotes.MoveCar
local inCar = false

local moveSpeed = 0
local turnSpeed = 0

local vehicle
local thrust
local ang

local function onSit(Sitting, seat)
	if Sitting == true then
		if seat:IsA("VehicleSeat") then
			inCar = true
			vehicle = seat.Parent
			thrust = vehicle.BodyThrust
			ang = vehicle.BodyAngularVelocity
			
			ContextActionService:BindAction("flip", flipCar, false, "v")
			ContextActionService:BindAction("forward", moveForward, false, "w")
			ContextActionService:BindAction("backward", moveBack, false, "s")
			ContextActionService:BindAction("right", turnRight, false, "d")
			ContextActionService:BindAction("left", turnLeft, false, "a")
		end
	else
		inCar = false
		ContextActionService:UnbindAction("flip")
		ContextActionService:UnbindAction("forward")
		ContextActionService:UnbindAction("backward")
		ContextActionService:UnbindAction("right")
		ContextActionService:UnbindAction("left")
	end
end

function flipCar(name, inputState)
	if name == "flip" then
		if inCar then
			if inputState == Enum.UserInputState.Begin then
				local seat = vehicle:FindFirstChildOfClass("VehicleSeat")
				local bodyGyro = Instance.new("BodyGyro", seat)
				
				repeat wait() 
					if bodyGyro then
						seat:FindFirstChild("BodyGyro").MaxTorque = Vector3.new(1000, 0, 1000)
					end 
				until seat.Orientation.Z < 0.3 and seat.Orientation.Z > -0.1
				
				bodyGyro:Destroy()
			end
		end
	end
end

function moveForward(name, inputState)
	if name == "forward" then
		if inCar then
			if inputState == Enum.UserInputState.Begin then
				moveSpeed = 30
			end
			
			if inputState == Enum.UserInputState.End then
				moveSpeed = 0
			end
		end
	end
end

function moveBack(name, inputState)
	if name == "backward" then
		if inCar then
			if inputState == Enum.UserInputState.Begin then
				moveSpeed = -30
			end
			
			if inputState == Enum.UserInputState.End then
				moveSpeed = 0
			end
		end
	end
end

function turnRight(name, inputState)
	if name == "right" then
		if inCar then
			if inputState == Enum.UserInputState.Begin then
				turnSpeed = 10
			end
			
			if inputState == Enum.UserInputState.End then
				turnSpeed = 0
			end
		end
	end
end

function turnLeft(name, inputState)
	if name == "left" then
		if inCar then
			if inputState == Enum.UserInputState.Begin then
				turnSpeed = -10
			end
			
			if inputState == Enum.UserInputState.End then
				turnSpeed = 0
			end
		end
	end
end

runService:BindToRenderStep("Update", Enum.RenderPriority.Input.Value, function()
	if inCar then
		thrust.Force = vehicle.PrimaryPart.CFrame.lookVector * Vector3.new(0, 0, -moveSpeed) * 1000
		ang.AngularVelocity = Vector3.new(0, turnSpeed, 0)
	end
end)

humanoid.Seated:Connect(onSit)
1 Like

Im having a similar problem with the vehicle seat, since I’ve been working on days on my car, but when people test it they can’t drive, I figured out why, and its beacuse they have a blocky body, I need help fixing that, please answer if you can help me, thanks, I would appreciate it a lot

There could be a number of things going on here, but I’m going to suggest an alternative to movement that I think is gunna save you a whole lot of hassle. The default ControlModule has this really great feature where you can get the player’s movement input as a vector and I use it all the time (especially great because it works for all platforms). Here’s how I would go about this:

--Services
local PL = game:GetService("Players")
local RunService = game:GetService("RunService")

--Components
local player = PL.LocalPlayer

--Modules
local Controller = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("ControlModule"))

--Variables
local MOVE_SPEED = 30
local TURN_SPEED = 10

--Car Movement
RunService.RenderStepped:Connect(function()
	
	--Setup
	local move = Controller:GetMoveVector() --This is a Vector3 of the Players Movement (Side,0,Forward) each is between -1 and 1
	
	--Movement
	thrust.Force = vehicle.PrimaryPart.CFrame.lookVector * MOVE_SPEED * move.Z
	ang.AngularVelocity = Vector3.new(0, TURN_SPEED * -move.X, 0)
	
end)

Obviously I’m missing some of the stuff you had in yours such as “inCar” but I’m assuming those were not the issue. Let me know if you have any questions!