How to eject passengers when you delete a car?

I made a script that spawns and deletes a car. I managed to eject the person who spawned the car, but I’m not able to eject any passengers sitting in the vehicle.

If I don’t eject the passengers sitting in the vehicle before it is deleted, then their character starts ice skating and their seat animations won’t stop playing.

I have currently placed the script in Serverscriptservice.

Solutions I have tried so far:

  • I tried to disable humanoid.sit in the vehicle seat’s Occupant, but it did not work.
  • I tried to delete the SeatWeld to eject the vehicle seat’s occupant, but it did not work.
  • I tried to get the parent of the vehicle seat’s occupant and use :GetPlayerFromCharacter and remove all animations and set customphysicalproperties to standard, but it did not work.

Videos on the problem:


Thanks in Advance!

1 Like

You can simply do
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
this will make the player jump therefore ejecting them out the vehicle

I believe there is a jump property within the humanoid, if you set that to true it will force them to jump.
https://developer.roblox.com/en-us/api-reference/property/Humanoid/Jump

I’m currently trying that, if it doesn’t work, I’ll let you know.

1 Like

It didn’t work. It just doesn’t want to get the occupant of the seat, and we can’t just force all the players in the game to jump. It isn’t able to print the occupant.

Is there an error? Can you please put it here?

No errors, but nothing in the output.

Kay then try this it’s an alternative way to make the player jump
humanoid.Jump = true

Setting jump to true just brought back the skating thing for the driver.

When the player sits in the car are you setting the
Humanoid.PlatformStand = true
?

No, it is false. But it changes the physical properties of the character which prevents extra mass on suspensions.

Well, whatever you changed with the character you will need to change back to normal.

Can you share the code for when the player sits in the car?

I use A-chassis, which uses SeatWelds.

So when the player touches the seat part they sit? That’s probably what’s causing the issue. After the player leaves the seat make sure to add a delay to when the seat’s CanTouch property will be back to true. You should just use a ProximityPrompt or ClickDetector with the seat’s CanTouch false

The car uses ProximityPrompts, I’m the other guy in the video btw

1 Like

So make sure the seat’s CanTouch property is set to False this makes sure that when you are leaving you are still touching the car but since we aren’t relying on the seat’s Touched seating we are good to go

It works, but it didn’t solve the skating issue.

Can you show me your car deleting script I can’t help you without even knowing the code

I was able to get the solution thanks to my friend @Cadentopia.

Here is the working delete script:

DeleteCarEvent.OnServerEvent:Connect(function(player, Car)
    local char = player.Character
    if Car then
        for _,v in pairs(Car.Body.Seats:GetChildren()) do
            if v:IsA("VehicleSeat") then
                local occupant = v.Occupant
                if occupant ~= nil then
                    occupant.Jump = true
                end
                wait(0.05)
                v:Destroy()
            end
        end
        wait(0.2)
        Car:Destroy()
    end
end)
5 Likes