Advertisement
Sungmingamerpro13

STORY GAME LOBBYHandler

Oct 22nd, 2022
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. local placeId = 11155396403
  2. local tps = game:GetService("TeleportService")
  3.  
  4. local ts = game:GetService("TweenService")
  5.  
  6. local lifts = workspace:WaitForChild("Lobby"):WaitForChild("Lifts")
  7.  
  8.  
  9. for i, lift in pairs(lifts:GetChildren()) do
  10.  
  11. local playerLimit = tonumber(lift.Name)
  12.  
  13. local front = lift:WaitForChild("Front")
  14.  
  15. local gui = Instance.new("SurfaceGui")
  16. gui.PixelsPerStud = 60
  17. gui.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  18. gui.Parent = front
  19.  
  20. local label = Instance.new("TextLabel")
  21. label.Font = Enum.Font.Michroma
  22. label.BackgroundTransparency = 1
  23. label.TextColor3 = Color3.fromRGB(255, 255, 255)
  24. label.TextScaled = true
  25. label.Size = UDim2.new(1, 0, 1, 0)
  26. label.Text = "0/" .. playerLimit
  27. label.Parent = gui
  28.  
  29.  
  30. local playersIn = {}
  31. local playerDebounce = {}
  32.  
  33. front.Touched:Connect(function(hit)
  34.  
  35. local char = hit.Parent
  36. local plr = game.Players:GetPlayerFromCharacter(char)
  37.  
  38. if plr and not playerDebounce[plr] then
  39.  
  40. playerDebounce[plr] = true
  41.  
  42. if table.find(playersIn, plr) then
  43. table.remove(playersIn, table.find(playersIn, plr))
  44.  
  45. char.HumanoidRootPart.CFrame = front.CFrame + front.CFrame.LookVector * 3
  46.  
  47. elseif #playersIn < playerLimit then
  48. table.insert(playersIn, plr)
  49.  
  50. char.HumanoidRootPart.CFrame = lift.Lift.PrimaryPart.CFrame + Vector3.new(0, 5, 0)
  51. end
  52.  
  53. task.wait(1)
  54. playerDebounce[plr] = false
  55. end
  56. end)
  57.  
  58.  
  59. local countdown = 31
  60.  
  61. local cfValue = Instance.new("CFrameValue")
  62. cfValue.Value = lift.Lift.PrimaryPart.CFrame
  63.  
  64. cfValue:GetPropertyChangedSignal("Value"):Connect(function()
  65. lift.Lift:SetPrimaryPartCFrame(cfValue.Value)
  66. end)
  67.  
  68.  
  69. task.spawn(function()
  70. while task.wait(1) do
  71. if #playersIn > 0 then
  72. countdown -= 1
  73. else
  74. countdown = 31
  75. end
  76.  
  77. label.Text = #playersIn .. "/" .. playerLimit .. "\n" .. countdown .. "s"
  78.  
  79. if countdown <= 0 then
  80.  
  81. local ti = TweenInfo.new(4.5, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
  82. local originalCF = cfValue.Value
  83. local goalCF = originalCF - Vector3.new(0, 16, 0)
  84.  
  85. ts:Create(cfValue, ti, {Value = goalCF}):Play()
  86.  
  87. task.wait(5)
  88.  
  89. local options = Instance.new("TeleportOptions")
  90. options.ShouldReserveServer = true
  91.  
  92. tps:TeleportAsync(placeId, playersIn, options)
  93.  
  94. ts:Create(cfValue, ti, {Value = originalCF})
  95.  
  96. playersIn = {}
  97. end
  98. end
  99. end)
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement