How to change a-chassis keybind to exit/enter vehicle?

I am currently working on a custom vehicle chassis(based on a-chassis) and I cant figure out how to change the exit keybind of the vehicle, i.e, instead of pressing spacebar you have to press another button. Not to sure but I believe it also requires disabling the jump button when player enters the vehicle and enable it when they exit the vehicle.Also want to make it so the player can only enter vehicle with PorximityPromt This is the script I am trying to work with

--[[Driver Handling]]

	--Driver Sit	
	car.DriveSeat.ChildAdded:connect(function(child)
		if child.Name=="SeatWeld" and child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
			--Distribute Client Interface
			local p=game.Players:GetPlayerFromCharacter(child.Part1.Parent)
			car.DriveSeat:SetNetworkOwner(p)
			local g=script.Parent["A-Chassis Interface"]:Clone()
			g.Parent=p.PlayerGui
		end
	end)
	
	--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()
							v["#AV"].MaxTorque = Vector3.new()
						end
					else
						if v["#AV"].AngularVelocity>0 then
							v["#AV"].AngularVelocity = 0
							v["#AV"].MotorMaxTorque = 0
						end
					end
				end
			end
		end
	end)

And the module

--Weld stuff here

car.DriveSeat.ChildAdded:connect(function(child)
	if child.Name=="SeatWeld" and child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
		child.C0=CFrame.new(0,-.5,0)*CFrame.fromEulerAnglesXYZ(-(math.pi/2),0,0)*CFrame.Angles(math.rad(13),0,0)
	end
end)

(yes they both are in a-chassis script)

Don’t see spacebar here anyplace. You sure this isn’t coming from a local script?

2 Likes

yes, the first script is called 'initialize and the second one is a module script called MiscWeld

they both are a-chassis script

Edit: I dont think there is a default keybind, it maybe just detects when the player jumps. I couldnt figure out how to turn it into a keybind

Is this one of them vehicle scripts that use a ProximityPrompt letter E to enter. If so try the E to exit. IF that works you may just need to stop the player from jumping while seated.

1 Like

Yes it is, however i dont know how to use the enum keybind code in the above to make user exit vehicle seat. is there a way it changes the player’s avatar position from sitting to standing or a way to make the avatar jump?

So will the E key exit the player from the seat. Need to know if this is the case 1st. If so we can just stop them from jumping while in the seat. Jump should exit them also … but I thought you were looking to change that so they can’t jump … How do you want this to work?

Firstly I want to disable the jumping so I can use the space button for vehicle handbrake. So I want to make it that pressing E will allow the player to exit vehicle, and also find a way to make the player sit on the vehicleseat when player presses E and make the ProximityPrompt disappear so it doesnt annoy while driving

(Srry for late reply)

Local Script in StarterCharacterScripts … xJump

local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
	humanoid.Jump = false
end)

This model is doing pretty much what you’re looking for. Not related to xJump
Dune Buggy

1 Like

Ran into a spot I needed to keep the player in the seat. Came up with this …
Not sure if this helps you but, it has some new ways of using the commands.

local player=game:GetService("Players").LocalPlayer
local character=player.Character or player.CharacterAdded:Wait()
local humanoid=character:WaitForChild("Humanoid")

humanoid.Seated:Connect(function(_,seat)
	if seat then
		humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
			humanoid.Jump=false
		end)
		humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
			humanoid.Sit=true
		end)
	end
end)

Bonus: This stops the player from jumping. One time call.

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

A seat however is doing more than jumping to exit. so …

humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
	humanoid.Sit=true
end)

Seems to pick that up as well.

This turned out to be pretty hard. This worked for me …
In a local script and you have to make sure other scripts are not setting this also.

The cas part stops the spacebar from working at all.
The uis part makes the E key jump.

local cas=game:GetService("ContextActionService")
cas:BindActionAtPriority("jumpAction", function(_, inputState, _)
end, false, 1, Enum.KeyCode.Space)

local uis=game:GetService("UserInputService")
uis.InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.E and not gameProcessedEvent then
		occupant.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
    end
end

source …
temporarily-changing-the-jump-key
And this also removes the spacebar … cas:UnbindAction(“jumpAction”)
In my case I just want them to be stuck in the seat. From the post it looks like you can bring it back the spacebar also.

Also something about .Sink to keep the key working, just not doing the default action. I’m a bit lost, so. Here is a link to that … ContextActionService
I can get it to turn off. Just can’t seem to get it to turn jump from spacebar back on after you leave the seat. Apparently you just call it again. Don’t seem to work for me.

1 Like

thanks, i will try to implement this, will tell you if it worked :slight_smile:

If you figure out how to bring back the jump to the space bar after they exit the seat let me know. I’ll be working on that soon enough.

I got it working …

local cas=game:GetService("ContextActionService")
cas:BindActionAtPriority("BlockSpace",function()
	return Enum.ContextActionResult.Sink -- works with or without this line (?)
end,false,9999,Enum.KeyCode.Space)

local uis=game:GetService("UserInputService")
uis.InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.E and db and not gameProcessedEvent then
		occupant.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
        cas:UnbindAction("BlockSpace") -- restores spacebar 
	end
end)

I guess .Sink is to make it so you can still use the key. Don’t seem to work here. But this is where I’m done. As this is now doing all I need. Adding the ProximityPrompt is easy enough to get them to sit. However you may want to add, in that script …

if humanoid.Sit==false then
	seat:Sit(humanoid)	
end

So they can’t press to jump to a new seat if close enough while in a seat … . Good luck.