How can I make a script detect when a player exits a seat and teleports them to another part?

I’m trying to make a car teleport you out of it to an invisible part next to it. I know how to find who is on the seat as seen in the script here.

 Seat.ChildAdded:Connect(function(child)
    	if child.Name == "SeatWeld" then
    		player = child.Part1.Parent
    	end
    end) 

Unfortunately, I cannot figure out how to make the script detect when the player has jumped out. Any ideas?

Edits were made to make things a bit clearer

I’ve made a reply on something like this and here it is:

I hope it helps.

P.S- When checking for the seat.Occupant that’s when you’re checking if the player sat down and for the else, that’s when the player got up. Sorry if I didn’t explain it fully, I’m currently in a rush.

1 Like

Alright so the detection for seats works perfectly but I can’t figure out the whole teleport thing. (Sorry I’m such an idiot lol)

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if (Seat.Occupant) then
		humanoid = Seat.Occupant
		print("Entered seat")
		
	else
		wait()
		local exit = script.Parent.Parent.Body.FrontLeft
		print("Exited seat")
		humanoid.Parent.HumanoidRootPart.CFrame = CFrame.new(exit.Position)
	end
end)

When I attempt to teleport to said part, all my avatar does is simply jump out and not teleport. No errors pop up in the output. Any idea what to do here?

Humanoid.Seated. If the first parameter is false, teleport them to the exit position.

Here’s a related thread: How can I detect when a player sits - #3 by OnlyJaycbee

Please search around before posting your issue as this has been posted before.

All of these are good answers but I’m trying to get my avatar to teleport when the game detects that it jumps out (and the game does detect it now). When I tried to use CFrame to teleport, my character simply jumps out and doesn’t teleport over to the desired location.

UPDATE: Turns out I’m an idiot and didn’t realize the part I was teleporting to was not anchored. Thanks for the help