local TS = game:GetService("TeleportService") local GuiPart = script.Parent.Parent.GuiPart local Seats = script.Parent.Parent.BusModel.SeatsModel:GetChildren() local List = {} local MinPlayers = 1 local MaxPlayers = 12 local Timer local PlaceId = (17424851138) GuiPart.SurfaceGui.Players.Text = "Players: "..#List.." / "..MaxPlayers local function removeFromList(character) for i=1,#List do if List[i] == character.Name then table.remove(List,i) GuiPart.SurfaceGui.Players.Text = "Players: "..#List.." / "..MaxPlayers end end end local function TeleportPlayers() if #List >= MinPlayers then GuiPart.SurfaceGui.Status.Text = "Teleporting..." GuiPart.SurfaceGui.Status.TextColor3 = Color3.new(1, 0, 0) local playersToTeleport = {} for i=1,#List do if game.Players:FindFirstChild(List[i]) then table.insert(playersToTeleport, game.Players:FindFirstChild(List[i])) game.ReplicatedStorage.TransitionEvent:FireClient(game.Players:FindFirstChild(List[i])) else table.remove(List,i) end end local Code = TS:ReserveServer(PlaceId) TS:TeleportToPrivateServer(PlaceId, Code, playersToTeleport) repeat wait() until #List <= 0 GuiPart.SurfaceGui.Status.Text = "READY" GuiPart.SurfaceGui.Status.TextColor3 = Color3.new(0.333333, 1, 0) else GuiPart.SurfaceGui.Players.Text = "1 Players Neeeded" wait(2.5) GuiPart.SurfaceGui.Players.Text = "Players: "..#List.." / "..MaxPlayers end end script.Parent.Touched:Connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") then local character = Hit.Parent local Player = game.Players:GetPlayerFromCharacter(character) local alreadyExists = false for i=1,#List do if List[i] == character.Name then alreadyExists = true end end if alreadyExists == false then if #List < MinPlayers then table.insert(List,character.Name) for i, v in pairs(Seats) do if Seats == nil then local Check = Instance.new("Weld") Check.Name = "Check" Check.Parent = Player.Character Check.Parent.Humanoid.JumpPower = 0 Check.Parent.Humanoid.WalkSpeed = 0 end end Seats[math.random(1, #Seats)]:Sit(Player.Character.Humanoid) game.ServerStorage.LeaveGui:Clone().Parent = Player.PlayerGui GuiPart.SurfaceGui.Players.Text = "Players: "..#List.." / "..MaxPlayers end end Player.CharacterRemoving:connect(function(character) removeFromList(character) end) end end) game.ReplicatedStorage.LeaveGuiEvent.OnServerEvent:Connect(function(player) player:LoadCharacter() end) while wait() do Timer = 41 for i=1,Timer do Timer = Timer - 1 GuiPart.SurfaceGui.timeLabel.Text = "Time: "..Timer wait(1) end TeleportPlayers() end