Advertisement
Sungmingamerpro13

New BusTeleport styled Aquarium Story

Feb 21st, 2025
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 3.04 KB | None | 0 0
  1. local BusLeave = game.ReplicatedStorage:WaitForChild("LeaveGuiEvent")
  2. local teleportService = game:GetService('TeleportService')
  3. local players = game:GetService('Players')
  4. local BusEnter = script.Parent.BusEnter
  5. local Bus = script.Parent.Parent.Bus
  6. local seats = Bus:FindFirstChild("Seats"):GetChildren()
  7. local billBoard = script.Parent.billboardPart.billboardGui
  8. local joinable = true
  9. local busTable = {}
  10. local MinPlayers = 1
  11. local MaxPlayers = 12
  12. local PlaceId = script.TeleportID.Value
  13.  
  14. billBoard.Frame.players.Text = MaxPlayers.." Spaces Left"
  15.  
  16. BusEnter.Touched:Connect(function(Hit)
  17.     if Hit.Parent:FindFirstChild("Humanoid") then
  18.        
  19.         local character = Hit.Parent
  20.         local player = game.Players:GetPlayerFromCharacter(character)
  21.        
  22.         for _, seat in pairs(seats) do
  23.             if seat.Occupant == nil and joinable and not table.find(busTable,player) then
  24.                 table.insert(busTable,player)
  25.                 player.Character.Humanoid.JumpPower = 0
  26.                 seat:Sit(player.Character.Humanoid)
  27.                 game.ServerStorage.LeaveGui:Clone().Parent = player.PlayerGui
  28.                 BusEnter.PlayerCount.Value = BusEnter.PlayerCount.Value - 1
  29.                 break
  30.             end
  31.         end
  32.     end
  33. end)
  34.  
  35. BusLeave.OnServerEvent:Connect(function(player)
  36.     local returnValue = table.find(busTable,player)
  37.     if returnValue then
  38.         table.remove(busTable,returnValue)
  39.         player.Character.Humanoid.JumpPower = 50
  40.         player.Character.Humanoid.Sit = false
  41.         BusEnter.PlayerCount.Value = BusEnter.PlayerCount.Value + 1
  42.         wait(.4)
  43.         player:LoadCharacter()
  44.     end
  45. end)
  46.  
  47. BusEnter.PlayerCount:GetPropertyChangedSignal('Value'):Connect(function()
  48.     billBoard.Frame.players.Text = BusEnter.PlayerCount.Value.." Spcaes Left"
  49. end)
  50.  
  51. while wait(1) do
  52.     for i = 41,0,-1 do
  53.         if i == 0 and #busTable >= MinPlayers then
  54.             joinable = false
  55.             billBoard.Frame.Status.TextColor3 = Color3.fromRGB(255,0,0)
  56.             billBoard.Frame.Status.Text = 'Teleporting!'
  57.             billBoard.Frame.Status.TextColor3 = Color3.fromRGB(62, 197, 255)
  58.             for i = 1, 100 do -- Moves car forward 100 studs.
  59.                 Bus:TranslateBy(Vector3.new(212.5, 12.5, -1.5))
  60.                 wait()
  61.             end
  62.             local code = teleportService:ReserveServer(PlaceId)
  63.             teleportService:TeleportToPrivateServer(PlaceId,code,busTable)
  64.             for _, player in pairs(busTable) do
  65.                 game.ServerStorage.TransitionGui:Clone().Parent = player.PlayerGui
  66.             end
  67.             wait(10)
  68.             for i = 1, 100 do -- Moves car forward 100 studs.
  69.                 Bus:TranslateBy(Vector3.new(49.5, 12.5, -1.5))
  70.                 wait()
  71.             end
  72.             repeat wait() until #busTable == 0
  73.             billBoard.Frame.Status.TextColor3 = Color3.fromRGB(17, 255, 0)
  74.             billBoard.Frame.Status.Text = 'Enter Bus'
  75.             joinable = true
  76.         elseif i == 0 and #busTable < MinPlayers then
  77.             --- not enough players!
  78.         elseif i == 0 and #busTable > MaxPlayers then
  79.             -- 12 Players Teleporing To Main Game!
  80.         end
  81.         billBoard.Frame.time.Text = 'Time: '..i
  82.         wait(1)
  83.     end
  84. end
  85.  
  86. players.PlayerRemoving:Connect(function(player)
  87.     local returnValue = table.find(busTable,player)
  88.     if returnValue then
  89.         table.remove(busTable,returnValue)
  90.         BusEnter.PlayerCount.Value = #busTable
  91.     end
  92. end)
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement