Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local MinimumPlayers = 1
- local PFolder = game.Workspace.PFolder
- local CurrentGame = 0
- local CurrentGameName = "None"
- local GP = game.Workspace.Game
- local IT = 5
- local CT = 1
- local PlayerCount = script.PC
- local GameStarted = false
- local CanStart = false
- local GameS = game.ReplicatedStorage.Remotes.Game
- local PanelMap = game.Lighting:FindFirstChild("Panele")
- local WinDB = false
- Players.PlayerAdded:Connect(function(Player)
- Player.CharacterAdded:Connect(function(Character)
- local AFK = Instance.new("BoolValue")
- AFK.Name = "AFK"
- AFK.Value = false
- AFK.Parent = Character
- local INGAME = Instance.new("BoolValue")
- INGAME.Name = "INGAME"
- INGAME.Value = false
- INGAME.Parent = Character
- for _, acc in ipairs(Character:GetChildren()) do
- if acc:IsA("Accessory") then
- acc:FindFirstChild("Handle").CanCollide = false
- end
- end
- end)
- Player.CharacterRemoving:Connect(function(character)
- if character:FindFirstChild("INGAME").Value == true then
- PlayerCount.Value -= 1
- print("Usunieto gracza! jest ich: "..PlayerCount.Value)
- end
- end)
- local function onCharacterDespawned(char)
- if char:FindFirstChild("INGAME").Value == true then
- PlayerCount.Value -= 1
- print("Usunieto gracza! jest ich: "..PlayerCount.Value)
- end
- end
- end)
- while GameStarted == false and GameS.Value == false do
- wait(IT)
- CurrentGame = math.random(1,1)
- if CurrentGame == 1 then
- for _, player in pairs(game:GetService("Players"):GetPlayers())do
- CurrentGameName = "Hexagon Run"
- while true do
- game.ReplicatedStorage.Events.Text:FireClient(player,'Choosed game: '..CurrentGameName)
- PanelMap.Parent = game.Workspace
- if player and player.Character and player.Character.AFK.Value == false then
- PlayerCount.Value += 1
- print("Dodano gracza! jest ich: "..PlayerCount.Value)
- if PlayerCount.Value > MinimumPlayers then
- print("Aktualnie jest ich: "..PlayerCount.Value)
- player.Character.Parent = PFolder
- player.Character:FindFirstChild("INGAME").Value = true
- player.Character:MoveTo(GP.Position)
- game.ReplicatedStorage.Events.Text:FireClient(player,'Start!')
- wait(1)
- game.ReplicatedStorage.Events.CloseGui:FireClient(player)
- if GameS.Value == false then
- GameS.Value = true
- end
- if GameStarted == false then
- GameStarted = true
- end
- if WinDB == false then
- WinDB = true
- end
- else
- print(PlayerCount.Value)
- game.ReplicatedStorage.Events.Text:FireClient(player,'Too few players to start game!')
- wait(3)
- if GameS.Value == true then
- GameS.Value = false
- end
- if GameStarted == true then
- GameStarted = false
- print("Gra nie wystartowala")
- end
- if PlayerCount.Value > 0 then
- PlayerCount.Value -= 1
- print("Usunieto gracza! jest ich: "..PlayerCount.Value)
- end
- print(PlayerCount.Value)
- end
- while WinDB == true and PlayerCount.Value == 1 do
- WinDB = false
- local plrs = PFolder:GetChildren()
- for i = 1, #plrs do
- local plr = game.Players:GetPlayerFromCharacter(plrs[i])
- plr.leaderstats.Wins.Value += 1
- game.ReplicatedStorage.Events.Text:FireClient(player, plr.Name..' won the game!')
- plr:LoadCharacter()
- wait(3)
- if GameS.Value == true then
- GameS.Value = false
- end
- if GameStarted == true then
- GameStarted = false
- end
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement