Advertisement
SimTek

AddToQueue

Apr 4th, 2024
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. local clicker = script.Parent
  2. local cs = game:GetService("CollectionService")
  3. local signIn = clicker.Parent.Parent
  4. local placeName = signIn.Configuration.PlaceName.Value
  5. local rs = game:GetService("ReplicatedStorage")
  6. local purgeBattleRe = rs:WaitForChild("PurgeBattleRe")
  7. local placeId = signIn.Configuration.PlaceId.Value
  8. local snd = signIn.Announcement
  9. local battleLbl = signIn.Wall.SurfaceGui.BattleLbl
  10. local ts = game:GetService("TeleportService")
  11.  
  12. clicker.MouseClick:Connect(function(player)
  13.     local tag = cs:HasTag(player, placeName)
  14.    
  15.     if tag then
  16.         print("remove player in the queue", player.Name)
  17.         purgeBattleRe:FireClient(player, false)
  18.         cs:RemoveTag(player, placeName)
  19.     else
  20.         print("add player to the queue", player.Name)
  21.         purgeBattleRe:FireClient(player, true)
  22.         cs:AddTag(player, placeName)
  23.     end
  24. end)
  25.  
  26. while true do
  27.     local lst = cs:GetTagged(placeName)
  28.     print("lst = ", lst)
  29.     if lst and #lst > 0 then
  30.         snd:Play()
  31.         for i=10, 1, -1 do
  32.             print("count down = ", i)
  33.             battleLbl.Text = "The " .. placeName .. " is starting in "
  34.                 .. i .. " seconds with " .. #lst .. " players"
  35.             wait(1)
  36.             lst = cs:GetTagged(placeName)
  37.             if #lst == 0 then
  38.                 break
  39.             end
  40.         end
  41.         if #lst > 0 then
  42.             battleLbl.Text = "Teleporting... "
  43.             local code = ts:ReserveServer(placeId)
  44.             ts:TeleportToPrivateServer(placeId, code, lst)
  45.             wait(6)
  46.         end
  47.     end
  48.     wait(1)
  49.     battleLbl.Text = "The Purge Battle!"
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement