Eject a player from a seat

Hi! I am making a race car game, and I made it so that when a player hits the finish line, they should teleport to a part. Unfortunately, it seems like if they step on the finish line while in the car, it just ejects the player from the car and does not teleport them. I also noticed that when the player touches the finish line without the car (meaning they walk on it), it works fine. Is there any piece of code I could use to “eject” a player from the seat? Something close to what I want to achieve (note: The first line is just theoretical, I just am guessing how it might look like):

seat:Eject(player)
player.Character:MoveTo(part.Position)

Is there any code that is similar to the code I put above, or acts in the same way as the code I currently have:

player.Character:MoveTo(part.Position)

only works when the player is not in the car. Otherwise, it just pushes the player out of the car and does nothing else. Any help would be appreciated! Thank you!

1 Like

There are many methods you could use to achieve this, first off;

Before moving the player, you could jump them to eject them from the seat, e.g

player.Character.Humanoid.Jump = true
wait(.1)
player.Character.Humanoid.Jump = false -- so the player isn't continueously jumping
4 Likes

Thank you! Let me try this, and I’ll let you know if it works.

To add onto that, you should disable the seat after making the player jump so they wont be seated back again.

1 Like

There’s a cooldown lasting like 2 seconds before the seat is useable again anyway and I’d assume the player would’ve been teleported by then so it wouldn’t make much of a difference

1 Like

It worked! Thank you so much for the help!

Happy I could help, good luck with your project!

1 Like