Disable player exiting seat once seated

Hello. I am trying to disable the player from exiting a VehicleSeat once they enter. I have tried setting their JumpPower to 0 and this current code disables jumping once they are in the seat. The print statement on line 39 prints as expected, but I am still able to leave the seat.

Any help is appreciated!

Code:

The covered up code handles the movement for the sled, and is unrelated so I covered it.

3 Likes

Do this:

Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

Without the “humanoid” if statement, don’t use that. Seat.Occupant will ALWAYS be a character with a humanoid.

or

Humanoid.JumpPower = 0

Which basically prevents jumping.

You can maybe directly set the jump power to 0 by saying Humanoid.JumpPower = 0

I have tried both suggestions, which did not work.


The print statement still prints, but I can still eject out the seat.

1 Like

Already tried this with the response above.

1 Like

Since occupant is humanoid, why don’t you try “occupant.JumpPower = 0”? Just a last resort

1 Like

Is it the same with setting the JumpHeight to 0?

1 Like

Yes, neither options work sadly.

1 Like

This option also doesn’t work, it would be the same as putting humanoid.JumpPower = 0.

1 Like

How about whenever the player jumps out of the seat, immediately set Seat.Occupant back to the player’s humanoid?

2 Likes

Okay then why not manually welding the player to said part?

2 Likes

I mimiced this as best as I could

local seat = script.Parent
if not seat then warn("No seat") end

local function onSeatChanged()
	local occupant = seat.Occupant
	if occupant then
		print("occ found")
		local char = occupant.Parent
		if char then
			local hum = char:FindFirstChildOfClass("Humanoid")
			if hum then
				hum.UseJumpPower = true
				hum.JumpPower = 0
				print('disabled')
			end
		end
	end
end

seat:GetPropertyChangedSignal("Occupant"):Connect(onSeatChanged)

Just replace the seat with vehicle seat
The reason is that we have to tell the game we wanna use jumppower before setting it

3 Likes

Does it work now? Or is it buggy or something?

Character limit

1 Like

Would this work in a server script or do i have to put it as a local script?

1 Like

It has to be in a server script or it wont work

1 Like

Pretty sure you can’t even run local scripts in the workspace or anywhere besides gui’s and startercharacter and starterplayer scripts.

1 Like

Seat.Occupant is a humanoid.
refer this if that is what you want

This works, thank you so much and thank you to everyone who pitched in :slight_smile:

1 Like