The player is not teleported to the seat

Experienced scripters please help. When a player touches a TouchPart object, it does not teleport to one of the seats. The error is probably somewhere in lines 12-16. Thank you in advance

while true do
	
	local model = game.ServerStorage.pickuptrack:Clone()
	model.Parent = workspace
	
	for i = 0, 266 do
		model:PivotTo(model:GetPivot() + Vector3.new(3, 0, 0))
		wait()
	end
	
	for i = 15, 0, -1 do
		workspace.InvisibleWalls.TouchPart.Touched:Connect(function(hit)
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			for i, sit in pairs(model.seats:GetChildren()) do
				sit:Sit(player.Character.Humanoid)
			end
		end)
		
		workspace.Waittext.SurfaceGui.TextBox.Text = 'Wait '..i..' seconds'
		wait(1)
	end
	
	workspace.Waittext.SurfaceGui.TextBox.Text = 'Wait...'
	
	for i = 0, 266 do
		model:PivotTo(model:GetPivot() + Vector3.new(3, 0, 0))
		wait()
	end
	
	model:Destroy()
	
end
1 Like