Advertisement
sriyanto

Game Logic

May 11th, 2024
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | None | 0 0
  1. local Round = require(script.RoundModule)
  2.  
  3. local Door = require(script.DoorModule)
  4.  
  5. local Status = game.ReplicatedStorage:WaitForChild("Status")
  6.  
  7. while wait() do
  8.    
  9.     repeat
  10.        
  11.         local availablePlayers = {}
  12.        
  13.         for i, plr in pairs(game.Players:GetPlayers()) do
  14.             if not plr:FindFirstChild("InMenu") then
  15.                 table.insert(availablePlayers,plr)
  16.             end
  17.         end
  18.        
  19.         Status.Value = "2 'Ready' players Needed ("..#availablePlayers.."/2)"
  20.        
  21.         wait(2)
  22.        
  23.     until #availablePlayers >= 1
  24.    
  25.     Round.Intermission(5)
  26.    
  27.     local chosenChapter = Round.SelectChapter() -- This is the map currently in the chapters folder
  28.    
  29.     local clonedChapter = chosenChapter:Clone()
  30.     clonedChapter.Name = "Map"
  31.     clonedChapter.Parent = game.Workspace
  32.    
  33.     wait(2)
  34.    
  35.     if clonedChapter:FindFirstChild("Doors") then
  36.         Door.ActivateDoors(clonedChapter.Doors)
  37.     else
  38.         warn("Fatal error: You forgot to add the Doors folder to your map.")
  39.     end
  40.    
  41.    
  42.    
  43.     local contestants = {}
  44.    
  45.     for i, v in pairs(game.Players:GetPlayers()) do
  46.         if not v:FindFirstChild("InMenu") then
  47.             table.insert(contestants,v)
  48.             print("Added player "..v.Name.." to contestants")
  49.         end
  50.     end
  51.    
  52.    
  53.     local chosenPiggy = Round.ChoosePiggy(contestants)
  54.    
  55.     for i, v in pairs(contestants) do
  56.         if v == chosenPiggy then
  57.             table.remove(contestants,i)
  58.         end
  59.     end
  60.  
  61.     for i, v in pairs(contestants) do
  62.         if v ~= chosenPiggy then
  63.             print("Firing togglecrouch for player: "..v.Name)
  64.             game.ReplicatedStorage.ToggleCrouch:FireClient(v,true)
  65.         end
  66.     end
  67.  
  68.  
  69.    
  70.     wait(2)
  71.    
  72.     Round.DressPiggy(chosenPiggy)
  73.    
  74.     Round.TeleportPiggy(chosenPiggy)
  75.    
  76.     if clonedChapter:FindFirstChild("PlayerSpawns") then
  77.         Round.TeleportPlayers(contestants, clonedChapter.PlayerSpawns:GetChildren())
  78.     else
  79.         warn("Fatal Error: You didn't add a PlayerSpawns folder into your Map")
  80.     end
  81.    
  82.     Round.InsertTag(contestants,"Contestant")
  83.     Round.InsertTag({chosenPiggy},"Piggy")
  84.    
  85.     Round.StartRound(600,chosenPiggy,clonedChapter)
  86.    
  87.     contestants = {}
  88.    
  89.     for i, v in pairs(game.Players:GetPlayers()) do
  90.         if not v:FindFirstChild("InMenu") then
  91.             table.insert(contestants,v)
  92.         end
  93.     end
  94.    
  95.     if game.Workspace.Lobby:FindFirstChild("Spawns") then
  96.         Round.TeleportPlayers(contestants, game.Workspace.Lobby.Spawns:GetChildren())
  97.     else
  98.         warn("Fatal Error: You have not added a Spawns folder into your Lobby with the SpawnLocations inside. Please do this to make the script work.")
  99.     end
  100.    
  101.     clonedChapter:Destroy()
  102.    
  103.     Round.RemoveTags()
  104.    
  105.     wait(2)
  106. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement