Advertisement
Kezoto

Untitled

Feb 4th, 2021
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local MinimumPlayers = 1
  3. local PFolder = game.Workspace.PFolder
  4. local CurrentGame = 0
  5. local CurrentGameName = "None"
  6. local GP = game.Workspace.Game
  7. local IT = 5
  8. local CT = 1
  9. local PlayerCount = script.PC
  10. local GameStarted = false
  11. local CanStart = false
  12. local GameS = game.ReplicatedStorage.Remotes.Game
  13. local PanelMap = game.Lighting:FindFirstChild("Panele")
  14. local WinDB = false
  15. Players.PlayerAdded:Connect(function(Player)
  16.  
  17. Player.CharacterAdded:Connect(function(Character)
  18. local AFK = Instance.new("BoolValue")
  19. AFK.Name = "AFK"
  20. AFK.Value = false
  21. AFK.Parent = Character
  22. local INGAME = Instance.new("BoolValue")
  23. INGAME.Name = "INGAME"
  24. INGAME.Value = false
  25. INGAME.Parent = Character
  26.  
  27.  
  28. for _, acc in ipairs(Character:GetChildren()) do
  29. if acc:IsA("Accessory") then
  30. acc:FindFirstChild("Handle").CanCollide = false
  31. end
  32. end
  33. end)
  34. Player.CharacterRemoving:Connect(function(character)
  35. if character:FindFirstChild("INGAME").Value == true then
  36. PlayerCount.Value -= 1
  37. print("Usunieto gracza! jest ich: "..PlayerCount.Value)
  38. end
  39. end)
  40. local function onCharacterDespawned(char)
  41. if char:FindFirstChild("INGAME").Value == true then
  42. PlayerCount.Value -= 1
  43. print("Usunieto gracza! jest ich: "..PlayerCount.Value)
  44. end
  45. end
  46. end)
  47. while GameStarted == false and GameS.Value == false do
  48. wait(IT)
  49. CurrentGame = math.random(1,1)
  50. if CurrentGame == 1 then
  51. for _, player in pairs(game:GetService("Players"):GetPlayers())do
  52. CurrentGameName = "Hexagon Run"
  53. while true do
  54. game.ReplicatedStorage.Events.Text:FireClient(player,'Choosed game: '..CurrentGameName)
  55. PanelMap.Parent = game.Workspace
  56. if player and player.Character and player.Character.AFK.Value == false then
  57. PlayerCount.Value += 1
  58. print("Dodano gracza! jest ich: "..PlayerCount.Value)
  59. if PlayerCount.Value > MinimumPlayers then
  60. print("Aktualnie jest ich: "..PlayerCount.Value)
  61. player.Character.Parent = PFolder
  62. player.Character:FindFirstChild("INGAME").Value = true
  63. player.Character:MoveTo(GP.Position)
  64. game.ReplicatedStorage.Events.Text:FireClient(player,'Start!')
  65. wait(1)
  66. game.ReplicatedStorage.Events.CloseGui:FireClient(player)
  67. if GameS.Value == false then
  68. GameS.Value = true
  69. end
  70. if GameStarted == false then
  71. GameStarted = true
  72. end
  73. if WinDB == false then
  74. WinDB = true
  75. end
  76. else
  77. print(PlayerCount.Value)
  78. game.ReplicatedStorage.Events.Text:FireClient(player,'Too few players to start game!')
  79. wait(3)
  80. if GameS.Value == true then
  81. GameS.Value = false
  82. end
  83. if GameStarted == true then
  84. GameStarted = false
  85. print("Gra nie wystartowala")
  86. end
  87. if PlayerCount.Value > 0 then
  88. PlayerCount.Value -= 1
  89. print("Usunieto gracza! jest ich: "..PlayerCount.Value)
  90. end
  91. print(PlayerCount.Value)
  92. end
  93. while WinDB == true and PlayerCount.Value == 1 do
  94. WinDB = false
  95. local plrs = PFolder:GetChildren()
  96. for i = 1, #plrs do
  97. local plr = game.Players:GetPlayerFromCharacter(plrs[i])
  98. plr.leaderstats.Wins.Value += 1
  99. game.ReplicatedStorage.Events.Text:FireClient(player, plr.Name..' won the game!')
  100. plr:LoadCharacter()
  101. wait(3)
  102. if GameS.Value == true then
  103. GameS.Value = false
  104. end
  105. if GameStarted == true then
  106. GameStarted = false
  107. end
  108. end
  109. end
  110. end
  111. end
  112. end
  113. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement