Trouble making players successfully exit a vehicle

I’m currently having issues with having a player successfully exit a vehicle, this is how it is intended to go Dont worry about the car collisions making the car jump, this is a small bug that will be fixed

But I don’t know if its due to ping or fps count, but 50% of the time players get stuck inside of the car

Here’s the code I’m using to make players exit the vehicle:

local Seat = interaction.Parent
if Seat.Occupant then
	local Seatweld = Seat:FindFirstChild("SeatWeld")
	if Seatweld then
		local con
		con = Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
			local ClosestPart = GetClosestInteractive(player, Seat)
			player.Character.Humanoid.Sit = false
			player.Character.Humanoid.Jump = true
		player.Character.Humanoid.WalkSpeed = 16
		player.Character.Humanoid.JumpPower = 50
GetClosestInteractive Code
local function GetClosestInteractive(player, Seat)
	local CloseInteractives = {}

	local Suspect = Seat.Occupant

	for i,v in pairs(Car.Body.Parts:GetChildren()) do
		if v.Name == "EXIT" then
			local mag = (player.Character.HumanoidRootPart.Position - v.Position).magnitude
			if mag <= 45 then
				table.insert(CloseInteractives, {Mag = mag, Part = v})
	if #CloseInteractives == 1 then
		return CloseInteractives[1].Part
	elseif #CloseInteractives > 1 then
		table.sort(CloseInteractives, function(a,b) 
			return a.Mag < b.Mag
		return CloseInteractives[1].Part 
		return nil

Let me explain whenever a player request to exit, which they do by pressing “T” a remote event is fired and the server checks if there’s an occupant, and checks if the actual player requesting to exit a vehicle, I searched through the devforum and people suggested others to destroy the seatweld and then move the player, that didn’t work, then I got a suggestion to connect a event to see whenever the seat.Occupant changes and disconnect the event when its finished. I also did that, then I got suggested to add a small wait since the script is doing it too fast, which I did. Then I got suggested to make the humanoid.Sit, false, and mame the Humanoid.Jump, true. Then last suggestion to me was to make the Seat:Sit, nil which I also did, But I am still getting this issue as you could see by the gif/video linked above.

Any suggestions, changes that I can make to make it so it works as intended?
If any more information or screenshots, etc. Is needed please reply below, thank you!

And oh yea players get teleported or pivoted to the closest small invisible part near them

If you need to remove a player’s character from a seat you can destroy the weld instance which is automatically created whenever a player’s character touches the seat. This weld is named “SeatWeld” and can be found inside the seat instance itself, its purpose is to weld the player’s character to the seat.

Thanks for the reply! But I am already destroying the seatweld shown here:

If you’re moving the character via the server. You may be running into problems where the server doesn’t have the correct position of the player. Character movement should be handled by the client.

Okay, thank you! I’m going to try this.

1 Like