Player kicked out of seat after forced to sit

  1. What do you want to achieve? Keep it simple and clear!
    I am teleporting player into my game from a lobby, once they are in the game I wait for their character to be added, then I wait for their ancestry to be changed, then I wait for and grab the humanoid part. Then I force them to sit in a vehicle seat.

  2. What is the issue? Include screenshots / videos if possible!
    Immediately after being forced to sit in the vehicle seat which I know they are because they are automatically moved to the seat and an event print statement fires saying they did, the player’s character stands up and is no longer seated, yet player controls are not available ( I assume because its state is still sitting, not positive) I also have disabled jump power to 0 so the character does not move or jump or do anything. Its very odd, because other code sees the player as in the seat. And my print out never fires saying the seat is not occupied.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I searched around the forum and the web for solutions but I can’t seem to find any with this same issue. (Even though I found many posts about forcing players to sit.)

I am simply using VehicleSeat:Sit(humanoid) The exact same method works perfectly fine for my NPCs.

3 Likes

Although it’s probably very inefficient, perhaps use a while true loop with the sit function.

Have you tried moving them slightly near the seat, then onto it?

1 Like

They players aren’t able to move. They spawn and are put in the seat the moment its possible. I use GetPropertyChangedSignal() on both the vehicle and the humanoid to detect if they enter or exit the seat. It fires only the first time they are seated and by that point movement controls are disabled.

I also have another script that check if vehicle seats are empty that runs several seconds after the player is seated and it detects they are seated. The VehicleSeat controls are not active though so something buggy is going on.

Use this

image

script : (not mine, modified)

local dest = script.Parent.Parent.Seat

  function Touch(hit)

   	 local Pos = script.Parent.Parent:findFirstChild("Seat")
	 hit.Parent:moveTo(dest.Position) 
     wait(1) 
     script.Parent.Locked = false 
     script.Parent.Parent:findFirstChild(dest).Locked = false 
  end 

 script.Parent.Touched:connect(Touch)

Seats should be big enough for the player to sit in.

I don’t think that is going to work for me. I’m not even sure that code works and it essentially is just using the humanoid:moveTo function to make the character walk to the seat. I don’t want to have to do that and I’m pretty sure a player could just use the movement controls to move themselves somewhere else. I don’t want players walking around it messes up the game mechanics.

I did a test where I disabled the forced sit and simply manually directed my player character to the seat and it all works perfectly fine. The issue is definitely happening with the forced sit. I can only guess this is a bug with the built in touch event for the vehicle seat clashing with the sit function. Or since the touch event is only supposed to fire with physics movement, maybe its a problem with the forced sit not connecting the player controls? Idk. its really annoying though. I guess I’ll try moving the player character above the seat and “dropping” them into it, but something tells me I’m going to have an issue where sometimes the seat touch event doesn’t fire and the player won’t be seated.

Dropping the players onto the seats isn’t working either. I think I’ll try going soup nazi on it now and lock players into clear boxes with the vehicles and kick them from the server if they don’t mount up after a period of time. The issue with the VehicleSeat:Sit() needs addressed at some point though, there is no doubt some kind of bug going on with it.

Does the player sit at all? If so, why don’t you just change it’s JumpPower to 0?

Use seat’s sit function instead of teleporting.

Seat:Sit(Humanoid)

After more testing I found the player does sit sometimes. Jump power is already being set to 0. The IRL player is not causing the player to get out of the seat. There is some kind of glitch/bug happening whenever I use script to force a player to sit. Either the player doesn’t sit properly or the player sits and vehicle seat controls don’t work.

I will admit I was mistaken about the moveTo() function making the character walk. I have only ever used it on the Humanoid object and that is the functionality of it in that circumstance. I did not use the script you posted but the moveTo function used on the character model was successful in getting the player’s character seated. For the NPC I had to use the VehicleSeat:Sit() function. The moveTo() on the NPC did move the NPC to the seat but it only stood on top of it and was never seated. So the combo of the two is what ended up working. I also had to add a series of short waits to ensure the player character was fully loaded and the vehicles were fully loaded and ready before anything would work as expected. The end result is instant from the player’s perspective. There is still a weird issue going on with my NPC AI where he won’t start driving until I give him a good nudge but, this particular seat problem is resolved. Thank you everyone for your suggestions.

@XxELECTROFUSIONxX I decided to go ahead and give you the solution but I’m hoping people read though the rest of the posts when having a similar issue because the script you posted is convoluted and not easy to follow. Simply suggesting the use of the moveTo() function on the character model would have been better. Also calling it a “teleport” only added to the confusion and made me think of the teleportation service, which is quite a different thing. Any way thank you for your help.