Making a-chassis cars stop upon exit

Hello Developers!

I’m sure if any of you have dealt with a-chassis vehicles, you have had the following experience: If a player exits the vehicle without putting the vehicle in park, it just drives off forever unless something stops it. I have tried many solutions to fix this and still haven’t come to any solutions that have worked. Has anyone found a way to fix this?

Thanks!

3 Likes
while task.wait() do
	if not script.Parent.Occupant then
		script.Parent.MaxSpeed = 0
	else script.Parent.MaxSpeed = 100
	end
end

Server script, place inside the VehicleSeat instance of the vehicle.

local carSeat = script.Parent:WaitForChild("VehicleSeat")

carSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if carSeat.Occupant then --someone using car
		carSeat.MaxSpeed = 100
	elseif not carSeat.Occupant then --no one using car
		carSeat.MaxSpeed = 0
	end
end)

More efficient implementation of the same logic. You’ll need to place the 2nd script inside the vehicle model itself. Make sure the VehicleSeat instance is a direct child of that model so that the script can correctly reference it, like this:

image

1 Like

Alright, so I put 2 scripts in the vehicle. CarOff1 is the first script you gave, and CarOff2 is the second script you gave. The VehicleSeat name of the car is “DriveSeat” so I changed the “VehicleSeat” to “DriveSeat” on the second script. Unfortunately, these scripts don’t seem to be working.

Here are the scripts below and where I have placed them:

Screen Shot 2021-11-03 at 9.18.14 PM

1 Like

Is that DriveSeat a VehicleSeat instance or just a regular Seat instance?

1 Like

The DriveSeat is a VehicleSeat. The DriveSeat is what the driver sits in.

1 Like

How is speed of the vehicle controlled normally?

All the speed is controlled through the A-Chassis Tune.

local carSeat = script.Parent:WaitForChild("VehicleSeat")

carSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if carSeat.Occupant then --someone using car
		carSeat.MaxSpeed = 100
	elseif not carSeat.Occupant then --no one using car
		carSeat.MaxSpeed = 0
	end
end)

Insert this script somewhere suitable within that script and control the speed however it is managed in that script. I think the MaxSpeed property only works for more primitive vehicles.

Yeah, it doesn’t work. No worries though, A-Chassis is so incredibly confusing it’s not even funny. I really appreciate the help! I’ll try and reach out to an A-Chassis dev and see if they have a solution.

I had the same problem, the way I fixed it was to anchor the wheels when the driving seat isn’t occupied

Howdy! It seems like you haven’t discovered my plugin that can totally get rid of that problem without having to anchor the vehicle!

2 Likes

To control an A-Chassis car, you change _GThrot and _GBrake in the Drive localscript.
They are controlled similarly to vehicleseat values, from -1 to 1.

1 Like

Hi
if someone has a problem with the script and an error pops up, they probably have an older version of the chassis
<1.4 so if you want the script to work I recommend removing most of the script and adding

car.DriveSeat.ChildRemoved:connect(function(child)
if child.Name==“SeatWeld” and child:IsA(“Weld”) then
for i, v in pairs(car.Wheels:GetChildren()) do
v["#AV"].angularvelocity = Vector3.new(0,0,0)
v["#AV"].maxTorque = Vector3.new(2500,0,0)
end
end
end)

2 Likes

Is there a way to decrease the time until stopped? I know it depends on the initial speed, but is there a way to “divide” that time to make it shorter?

1 Like

you can always change “v[”#AV"].maxTorque = Vector3.new(2500,0,0)" to like 3500 or higher

1 Like

Hey, I just tested this and noticed that this is already in the script (I am using A-Chassis v6.52S2).

This code is at the end of Initialize script (Click to show)
	--Driver Leave
	car.DriveSeat.ChildRemoved:connect(function(child)
		if child.Name=="SeatWeld" and child:IsA("Weld") then
			--Remove Flip Force
			if car.DriveSeat:FindFirstChild("Flip")~=nil then
				car.DriveSeat.Flip.MaxTorque = Vector3.new()
			end
			
			--Remove Wheel Force
			for i,v in pairs(car.Wheels:GetChildren()) do
				if v:FindFirstChild("#AV")~=nil then
					if v["#AV"]:IsA("BodyAngularVelocity") then
						if v["#AV"].AngularVelocity.Magnitude>0 then
							v["#AV"].AngularVelocity = Vector3.new(0,0,0)
							v["#AV"].MaxTorque = Vector3.new(0,0,0)
						end
					else
						warn('Maracujá')
						if v["#AV"].AngularVelocity>0 then
							v["#AV"].AngularVelocity = 0
							v["#AV"].MotorMaxTorque = 0
						end
					end
				end
			end
		end
	end)

However, It doesn’t seems to work, the car just lose wheel force but continue foward until it stops after a long time going foward alone.

I already read some topics about this but still can’t solve this problem. Any help would be appreaciated.

Enabling parking brake when char leave vehicle seat: I’ve already tried activating the parking brake when the character leaves the DriveSeat, however this make the smoke effects on the wheels stay forever, as the drift plugin cannot remove them as the script is deleted when the player leaves the DriveSeat. So activating parking brake is not a solution also

Already tried MaxTorque = Vector3.new(X,0,0) with higher values for X but also unsucessful. :frowning:

Have you tried something like this?

1 Like

Thank you for the reply. Just tested it and still has no effect on reducing the car speed. I also tried with exorbitant values like 99999 instead of 4000 but still makes no difference.

I welded on parts; one for each wheel, like brakes.

When the player exists I change those parts to CanCollide = true.

Works great.