A Chassis Vehicle to Stop when Exited

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    My game has a huge basis on driving. I’d like to make it to where when a player exits any vehicle that is in motion, the vehicle stops, rather than continuing to travel until ending in a collision. A Chassis Tune.

  2. What is the issue? Include screenshots / videos if possible!
    Vehicle does not slow or stop when jumping from vehicle. I’ve attempted multiple different ideas, I’ve also used a Plugin called “Anti-Loop Plugin” and altered the script to deal with my specific issue, but no avail. The wheels in my vehicle models are anchored, I’m running out of options and searching the Dev Forum endlessly and trying all the solutions i’ve come across, but have yet found a solid working solution.
    GIF of my issue below:
    Roblox (gyazo.com)\

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I started off with this placed as a Script under DriveSeat. No luck.

local carSeat = script.Parent

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

I attempted using this as a local script placed into Plugins under A-Chassis Tune. Still no luck.
(From Anti-Loop Plugin)

local car = script.Parent.Parent
local _Tune = require(car["A-Chassis Tune"])

for i, v in pairs(car.Wheels:GetChildren()) do
	if v.Name == "FL" then
		v["#AV"].AngularVelocity = 0
		v["#AV"].MotorMaxTorque = 0
		v["#AV"].MotorMaxAcceleration = 1e308
	end
	if v.Name == "FR" then
		v["#AV"].AngularVelocity = 0
		v["#AV"].MotorMaxTorque = 0
		v["#AV"].MotorMaxAcceleration = 1e308
	end
	if v.Name == "RL" then
		v["#AV"].AngularVelocity = 0
		v["#AV"].MotorMaxTorque = 0
		v["#AV"].MotorMaxAcceleration = 1e308
	end
	if v.Name == "RR" then
		v["#AV"].AngularVelocity = 0
		v["#AV"].MotorMaxTorque = 0
		v["#AV"].MotorMaxAcceleration = 1e308
	end
end

car.DriveSeat.ChildRemoved:connect(function(child) 
	if child.Name=="SeatWeld" and child:IsA("Weld") then 
		for i, v in pairs(car.Wheels:GetChildren()) do
			if v.Name == "FL" then
				v["#AV"].AngularVelocity = 0
				v["#AV"].MotorMaxTorque = 0
				v["#AV"].MotorMaxAcceleration = 0
			end
			if v.Name == "FR" then
				v["#AV"].AngularVelocity = 0
				v["#AV"].MotorMaxTorque = 0
				v["#AV"].MotorMaxAcceleration = 0
			end
			if v.Name == "RL" then
				v["#AV"].AngularVelocity = 0
				v["#AV"].MotorMaxTorque = 0
				v["#AV"].MotorMaxAcceleration = 0
			end
			if v.Name == "RR" then
				v["#AV"].AngularVelocity = 0
				v["#AV"].MotorMaxTorque = 0
				v["#AV"].MotorMaxAcceleration = 0
			end
		end
	end 
end)

function exitIsOn()
	if _Tune.AutoStart == true then
			for i, v in pairs(car.Wheels:GetChildren()) do
				if _Tune.Config == "AWD" then
					if v.Name == "FL" then
						v["#BV"].MotorMaxTorque = _Tune.EBrakeForce
					end
					if v.Name == "FR" then
						v["#BV"].MotorMaxTorque = _Tune.EBrakeForce
					end
					if v.Name == "RL" then
						v["#BV"].MotorMaxTorque = _Tune.EBrakeForce
					end
					if v.Name == "RR" then
						v["#BV"].MotorMaxTorque = _Tune.EBrakeForce
					end	
				end
				if _Tune.Config == "FWD" then
					if v.Name == "FL" then
						v["#BV"].MotorMaxTorque = _Tune.EBrakeForce
					end
					if v.Name == "FR" then
						v["#BV"].MotorMaxTorque = _Tune.EBrakeForce
					end
					if v.Name == "RL" then
						v["#BV"].MotorMaxTorque = 0
					end
					if v.Name == "RR" then
						v["#BV"].MotorMaxTorque = 0
					end	
				end
				if _Tune.Config == "RWD" then
					if v.Name == "FL" then
						v["#BV"].MotorMaxTorque = 0
					end
					if v.Name == "FR" then
						v["#BV"].MotorMaxTorque = 0
					end
					if v.Name == "RL" then
						v["#BV"].MotorMaxTorque = _Tune.EBrakeForce
					end
					if v.Name == "RR" then
						v["#BV"].MotorMaxTorque = _Tune.EBrakeForce
					end	
				end
			end	
		end	
	end


car.DriveSeat.ChildRemoved:Connect(exitIsOn)

If anyone has any thoughts or possible solutions I could attempt, please let me know. I feel like this is such an easy task but my brain shuts down each time I try to think of a way to prevent the motion from continuing.

Thank you so much!!!

2 Likes

Did you try the last response in that same thread?

I did, but now that I look at it, I may have added it to the wrong area. That post states to add that script to the Drive script, which I’d assume is either A-Chassis Tune or a script within. It’s a little unclear on where exactly it needs to go.

What scripts do u have in there?

Hey there, thanks for the response again. Here is a sample of the contents of one of my vehicles.


Thanks again!

Ok here is what you should do, i tested and it works for me:

Go into the A-Chassis Tune and then A-Chassis Interface, open the local script Drive…

Inside that script find the section labeled Shutdown as shown:

and replace it with this in there… I showed it copied in there on previous pic but here is a copy and paste friendly version:

	car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name=="SeatWeld" and child:IsA("Weld") then
		_PBrake = not _PBrake
		wait(.2)
			script.Parent:Destroy()
		end
	end)

Let me know how this works, it works like a charm for me.

9 Likes

Holy cow, I had no idea that script even existed. Thanks for the walk-through, I really appreciate your help. It works like a charm!

1 Like

Awesome… glad to help. . . . :slight_smile:

I’m gonna bug you one last time, I’m messing with the script to see if I can get it to automatically release the parking brake when the vehicle is re-entered. What would be the best way to go about that do you think?

Thanks again!!!

Im mobile when i get to computer i can take a look.

1 Like

Ok try this… under the same script as before look for this section:

Then replace the Pre-Toggled PBrake with this:

	--Pre-Toggled PBrake
	for i,v in pairs(car.Wheels:GetChildren()) do
		if math.abs(v["#AV"].maxTorque.Magnitude-PBrakeForce)<1 then
			_PBrake=false
		end
	end
8 Likes

Sorry I had work or I would’ve responded sooner. That works perfect! You’re AWESOME! Thank you for all the help! :slight_smile:

3 Likes