VehicleSeat:Sit() not always working?

I’m using VehicleSeat:Sit() to force players to sit down, however it seems to not be working half the time.

This is my code:

-- Seat player
interaction.OnTriggered = function()
	vehicleSeat:Sit(Hum)
	print("Forced sit")
end

Result:

As you can see the first two attempts to sit down were fine, but on the third one I had to press the key several times. You can see “Forced sit” being printed in the output, which means the function is being fired without any errors. But for some reason it’s not sitting the player down. Has anyone else experienced this before?

From your video, it looks like you are calling :Sit() on the client. Try moving this into a RemoteEvent and calling it from the server.

1 Like

Ok, I’ll try it. But does it absolutely have to run from the server in order to fix this? Because I’d prefer to run it on the client to avoid the client-server delay

No. What’s probably happening is that the server doesn’t register the player as having gotten up from the seat, or the server registers the character’s interaction with the seat differently from the client’s. As the video shows and as far as the code is concerned, it still works from the client, just slightly finnicky.

Consider a debounce.

1 Like

Well in the video it just happened to work right away the first few times. Other times, it didn’t seat me at all until I pressed the interaction button a few times. So I doubt it had something to do with the server not registering the player getting up.

If the server sees the seat is occupied, it won’t sit the character down. That’s what I believe is happening here as well; my theory is that in one way or the other, the server is involved in the seat backend, engine-wise.

I can’t quite think of any other explanation as to why the behaviour would appear like this. The code clearly works and the character does sit upon running the code, only some times out of many the character doesn’t actually sit down.

1 Like

Makes sense if you consider the normal method of :Sit() being called: touched events. The client is basically calling Sit() over and over until the cooldown has expired.

I’m not sure if the cooldown is bypassed by calling Sit() directly. In my code, it doesn’t matter, because I am calling it from the server. There’s some immediate feedback on the client, so this doesn’t really feel bad at all.

Unless you want to spam Sit on the client until the humanoid is seated, or manually make the welds, calling it from the server is your best bet to reliably sit them.