How to make a player get teleported between seats

Is there a better way to make players get teleported between different seats? Because I’ve tried different methods and still end up with the same problems. Basically the player gets jumped from the seat but sometimes doesn’t actually get teleported at all. Does anybody know a good way to make players get teleported between seats without any problems? Thanks.

Here’s the script

task.spawn(function()
		repeat
		Player.Character.Humanoid.Jump = true		
		Front_Seat:Sit(Player.Character.Humanoid)
		wait(0.05)
		until Front_Seat.Occupant ~= nil
end)

With a bit of experimenting, I came up with a solution:

local seats: {[number]: Seat} = game:GetService("Workspace"):WaitForChild("Seats"):GetChildren()

for i, seat: Seat in ipairs(seats) do
	
	local nextSeat = seats[i % #seats + 1]

	seat:GetPropertyChangedSignal("Occupant"):Connect(function()
		local occupant: Humanoid? = seat.Occupant
		if not occupant then return end

		task.wait(3)

		if seat:FindFirstChild("SeatWeld") then
			seat.SeatWeld:Destroy()
		end
		
		occupant.StateChanged:Once(function(oldState)
			if oldState ~= Enum.HumanoidStateType.Seated then return end
			
			nextSeat:Sit(occupant)
		end)
	end)
end

This server-sided script loops through all seats in a “Seats” folder in workspace and makes the occupant sit in the next seat in the folder after 3 seconds of sitting.

Place file: Seat Teleport.rbxl (56.6 KB)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.