Advertisement
qsenko1

Buggy Intermission zone

Jul 8th, 2022
997
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.42 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local Zone = require(game.ReplicatedStorage.Zone)
  3. local Container = game.Workspace.IntermissionHitboxZone
  4. local Zone = Zone.new(Container)
  5. local PlayerDiplayFrame = game.Workspace.DescriptionPart.SurfaceGui.Frame.PlayersDisplayFrame
  6. local debounce = true
  7. local RemainingTime = 10
  8. local whilelooprunvalue = true
  9. local debounce2 = true
  10. local playersinzone = {}
  11. --idk whu this is here but yeah
  12. wait(6)
  13.  
  14. Zone.playerEntered:Connect(function(player)
  15.     if player then 
  16.         local userId = player.UserId
  17.         local thumbType = Enum.ThumbnailType.HeadShot
  18.         local thumbSize = Enum.ThumbnailSize.Size420x420
  19.         local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
  20.         if not PlayerDiplayFrame:FindFirstChild(player.Name) then
  21.         local PlayerImage = script.ImageLabel:Clone()
  22.         PlayerImage.Parent = PlayerDiplayFrame
  23.         PlayerImage.Image = content
  24.         PlayerImage.Name = player.Name
  25.         -- adding players to the table
  26.         table.insert(playersinzone,player.Name)
  27.         else
  28.            
  29.         end
  30.         wait(.6)
  31.         for i,v in pairs(PlayerDiplayFrame:GetChildren()) do
  32.             if v:IsA("ImageLabel") and v.Name == player.Name then
  33.                 print(v.Name .. " entered")
  34.                 --  print(game.Players:GetPlayers())
  35.                 --  local Players = game.Players:GetPlayers()
  36.                 --  script.Script.Disabled = false
  37.                 for i, theplayer in pairs(Players:GetPlayers()) do
  38.                     print(theplayer.Name)
  39.                     for i,v in pairs(PlayerDiplayFrame:GetChildren()) do
  40.                         if v:IsA("ImageLabel") and v.Name == theplayer.Name  then
  41.                             print(theplayer.Name)
  42.                             --  script.Script.Disabled = false
  43.                             if debounce == true then
  44.                                 debounce = false
  45.                                 wait(.1)
  46.                             end
  47.                             if whilelooprunvalue then
  48.                                 wait(.5)
  49.                                 whilelooprunvalue = false
  50.                              -- local co = coroutine.create((function()
  51.                                 while not debounce do
  52.                                     wait()
  53.                                 --  print("hi")
  54.                                     if not debounce and not whilelooprunvalue then
  55.                                         if RemainingTime < 1 and not debounce then
  56.                                             wait(.1)
  57.                                             PlayerDiplayFrame.Parent.QueueDescription.Text = "Teleporting All Players into the game"
  58.                                             PlayerDiplayFrame.Parent.QueueDescription.TextColor3 = Color3.fromRGB(0, 255, 0)   
  59.                                             print("teleporting players")
  60.                                             wait(1)
  61.                                             PlayerDiplayFrame.Parent.QueueDescription.Text = "Game will start after 50 seconds or                             0/24 players are in!"
  62.                                             PlayerDiplayFrame.Parent.QueueDescription.TextColor3 = Color3.fromRGB(255, 255, 255)                          
  63.                                             RemainingTime = 50
  64.                                             -- destroying all players is label
  65.                                             for i,v in pairs(PlayerDiplayFrame:GetChildren()) do
  66.                                                 if v:IsA("ImageLabel") then
  67.                                                    v:Destroy()
  68.                                                 end
  69.                                             end        
  70.                                             wait(.1)
  71.                                         -- adding all players in zone that stay after teleporting as labels
  72.                                             for i,playersimage in pairs(playersinzone) do
  73.                                                 if not PlayerDiplayFrame:FindFirstChild(playersinzone) then
  74.                                                     local PlayerImage = script.ImageLabel:Clone()
  75.                                                     PlayerImage.Parent = PlayerDiplayFrame
  76.                                                     PlayerImage.Image = content
  77.                                                     PlayerImage.Name = playersimage
  78.                                                     print(PlayerImage.Name)
  79.                                                 else
  80.  
  81.                                                 end
  82.                                             end                                
  83.                                             --whilelooprunvalue = true
  84.                                         else
  85.                                             if not whilelooprunvalue then -- not debounce and      
  86.                                                 RemainingTime = RemainingTime - 1
  87.                                                 PlayerDiplayFrame.Parent.QueueDescription.Text = "Game will start after " .. RemainingTime  .. " seconds or                             0/24 players are in!"
  88.                                                 print("Game will start after " .. RemainingTime  .. " seconds or                             0/24 players are in!")
  89.                                                 if RemainingTime == 3 then 
  90.                                                 PlayerDiplayFrame.Parent.QueueDescription.Text = [[Game will start after <font color="rgb(0, 255, 0)">3</font> seconds or                                                   0/24 players are in!]]
  91.                                                 elseif RemainingTime == 2 then
  92.                                                     PlayerDiplayFrame.Parent.QueueDescription.Text = [[Game will start after <font color="rgb(255, 255, 0)">2</font> seconds or                                                   0/24 players are in!]]   
  93.                                                 elseif RemainingTime == 1 then
  94.                                                     PlayerDiplayFrame.Parent.QueueDescription.Text = [[Game will start after <font color="rgb(255, 0, 0)">1 </font> seconds or                                                   0/24 players are in!]]
  95.                                                 end
  96.                                                
  97.                                                 wait(1)
  98.                                                
  99.                                             else
  100.                                                 PlayerDiplayFrame.Parent.QueueDescription.Text = "Game will start after " .. RemainingTime  .. " seconds or                             0/24 players are in!"
  101.                                                 RemainingTime = 50
  102.                                                 print("Debounce is true")
  103.                                               --whilelooprunvalue = true
  104.                                                 return
  105.                                             end
  106.                                         end
  107.                                     end            
  108.                                 end
  109.                                 --      end))  
  110.                                 --  coroutine.resume(co)
  111.                             end
  112.                         end
  113.                        
  114.                     --  break
  115.                     end
  116.                 end
  117.             end
  118.         end
  119.     end
  120. end)
  121.  
  122. Zone.playerExited:Connect(function(player)
  123.     if player then 
  124.         -- destroying current player is label
  125.         for i,v in pairs(PlayerDiplayFrame:GetChildren()) do
  126.             if v:IsA("ImageLabel") and v.Name == player.Name then
  127.                 v:Destroy()        
  128.             end
  129.         end
  130.  
  131.         for i, playersiserver in pairs(Players:GetPlayers()) do
  132.             for i,playerlabels in pairs(PlayerDiplayFrame:GetChildren()) do
  133.                 if playerlabels:IsA("ImageLabel") and playerlabels.Name == playersiserver.Name or playerlabels.Name == player.Name then
  134.                     warn("theres players in queue")
  135.                     break
  136.                 elseif not PlayerDiplayFrame:FindFirstChildOfClass("ImageLabel") then
  137.                     warn("theres no players in queue")
  138.                     print("Resetting Timer Because cant find Players")
  139.                     --      script.Script.Disabled = true
  140.                     task.wait(.5)
  141.                     debounce = true
  142.                     PlayerDiplayFrame.Parent.QueueDescription.Text = "Game will start after 50 seconds or                             0/24 players are in!"
  143.                     RemainingTime = 50             
  144.                     wait(.1)
  145.                     whilelooprunvalue = true
  146.                     break
  147.                 end
  148.             end
  149.         end
  150.         -- removing the players from the table
  151.         for i,removeplayers in pairs(playersinzone) do
  152.             print(i,removeplayers)
  153.             if removeplayers == player.Name then
  154.                 table.remove(playersinzone,i)
  155.                 print(removeplayers)
  156.                 print(playersinzone)
  157.             end
  158.         end
  159.     end
  160. end)
  161.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement