Getting out of a seat while not being able to jump?

I have an area in the game where the player cant jump (I set JumpHeight to 0 when the player enters). But when the player gets in a seat they can’t get out of it, as they cant jump. I tried setting the JumpHeight to .001 when they sit down, but that makes the player jump about 3 studs up when they try to get out of the seat. I also tried teleporting the player out of the seat when they get out of the seat to prevent actual jumping, but it still launched the player up 3 studs. I could use UserInputService to teleport them out of the seat when they press space, but then I would have to make multiple versions for console and phone too. Any other ways to get out of the seat without jumping up?

3 Likes

Instead of teleporting them when they try to exit the seat, set the Humanoid.Sit = false

1 Like

But that won’t solve the fact that I can’t detect when they try to exit the seat, it will just just “unsit” them.

Have you tried to make the player teleport out of the seat while making Humanoid.Sit = false

Use ContextActionService so you know when the player performs the jump action. Then set Humanoid.Sit = false

2 Likes

Yes, I did, but that still can’t detect if they jump, just make them exit the seat. The problem is that I cant detect if they try to jump out of the seat. I could make them exit it if I knew when they pressed space or the jump button.

When a player sits down in a seat, it creates a Weld object as a child of the seat. As @domboss37 mentioned, you can set Humanoid.Sit = false, but only after destroying the weld between the character and the seat.

As for detecting when they try to jump, you can use ContextActionService and bind a function using Enum.PlayerActions.CharacterJump.

4 Likes

You can remove the SeatWeld if you want to manually force the player to stop sitting. You can track if they hit the ‘Spacebar’ or any other button using UserInputService or ContextActionService. You simply need to remove the SeatWeld from the seat by doing something like:

seat:FindFirstChild("SeatWeld"):Destroy() --forces player to stand up.

If you use ContextActionService:BindAction() you can create a mobile button that’ll appear on screen / be binded to the Action you set.

https://developer.roblox.com/en-us/api-reference/function/ContextActionService/BindAction

If you have any questions feel free to ask!

2 Likes