Add a property to disable jumping out of Seats

As roblox moves away from its vestiges of default behavior, there is currently only one way to prevent a player from jumping out of a seat when they press the space bar: Don’t use Seat objects.

My vehicles used to rely on this behavior being overridden when the seat’s Disabled property was set to true (Seat:Sit(humanoid) would still work, but space bar would not jump the players out of the seat).

Recently, this behavior has changed. Now, regardless of anything (whether the Jumping state is enabled, whether it is immediately set to false), if the player hits space bar, they will jump out of the seat.

I recently made a workaround where I would re-seat the player if the Occupant property changes. However, as of a few days ago, this will crash the client, because now Seat:Sit(humanoid) will no longer re-seat the player if they player has just jumped out of the seat. This results in an infinite signal loop. Even waiting a Stepped tick before re-seating the player will not work, because I think the internals have changed to where the seat debounce is active for the Seat:Sit method

Making custom seats is fairly taxing and not as easy to copy roblox’s normal seating behavior. But it’s my only option at this point.

I think there should be a property of Seat objects that allows this jumping behavior to be overridden. As well as this, I don’t think the jumping debounce should be affecting the Sit function.

15 Likes

If you set jump power of the humanoid to zero, it stops the player from jumping out of seats.

2 Likes

So it does… but I imagine with the recent changes to seat behavior, even this hack will eventually stop working.

I think that, alternatively, seats should check for whether the “jumping” humanoid state is enabled before the players exit the seat.

3 Likes

Personally, I’ve found that creating my own vehicle seat was a much better approach. At the time I set out for doing so, GetPropertyChangedSignal wasn’t out yet. So I actually used Changed. But once GetPropertyChangedSignal came out I was able to better optimize my code. Therefore if you really need custom functionality on a seat. I recommend making your own.

2 Likes

Note: The debounce and crash only happen when this is done from the client. If done from the server, it should work as expected.

The crash will definitely be fixed, as will the debounce on Sit. As for your approach on preventing players from exiting seats, a property would probably not be the best way to control this. Adding bool toggles for optional behavior creates API bloat over time. In this case, you should just kill the jump keybind clientside while the player is sitting:

game:GetService("ContextActionService"):BindActionAtPriority("LockSeat", function()
    return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.High.Value, Enum.PlayerActions.CharacterJump)

You can unbind “LockSeat” when the player is removed from the seat via Lua or you’d like to give them the ability to exit themselves. This is preferable to disabling jumping, as jumping may not always be tied to seats (i.e. the jump keybind exits the seat, but it doesn’t actually make the character jump).

21 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.