Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- testing = false
- nowait = false
- Leaderboard.CreateTeam("Playing", PartColor.new(0, 200, 0))
- Leaderboard.CreateTeam("Spectating", PartColor.new(50, 50, 50))
- --Player Variables--
- playercount = 0 --Number of players on the server.
- playing = false --If the game is being played.
- playerstostart = 1 --Min num of players to start round
- --Map Variables--
- maps = {"Bricks", "Sand", "Slim", "Squares", "FloodedTown"} --Maps MAKE SURE TO ADD TO RESETMAPS() AND LOADMAP()
- mapcount = 5 --Map count
- countdownnumber = 15 --Countdown Game
- roundtime = 60 --Gameplay Game
- mapselect = false --If players are selecting map
- votedebunk = false
- playerteleporting = 0 --This is the number of spawns that are being used.
- --Choices--
- pad1 = 0 --Pad1 Votes
- pad2 = 0 --Pad2 Votes
- pad3 = 0 --Pad3 Votes
- pad1c = 0 --Pad1 Votes
- pad2c = 0 --Pad2 Votes
- pad3c = 0 --Pad3 Votes
- --Players who voted--
- pad1players = {}
- pad2players = {}
- pad3players = {}
- --Players playing--
- currentlyplaying = {}
- --Part Variables--
- gamesign = Workspace.GameSign
- if testing then
- countdownnumber = 10
- roundtime = 10
- Workspace.PlayArea.Cheat.Opacity = 255
- Workspace.PlayArea.Cheat.CanCollide = true
- end
- if nowait then
- countdownnumber = 0
- roundtime = 0
- Workspace.PlayArea.Cheat.Opacity = 255
- Workspace.PlayArea.Cheat.CanCollide = true
- end
- ---------------------------------------------------------------------------
- --Functions--
- --Choosing Map--
- function choosemap()
- Workspace.PlayArea.HowLong.Text = "Choosing Map!"
- mapselect = true
- for i,v in pairs(Workspace.GamePads:GetChildren()) do
- local choosing = maps[math.random(1, mapcount)]
- if v.Name == "GamePad1" or v.Name == "GamePad2" or v.Name == "GamePad3" then
- v:FindFirstChild("MapName").Text = choosing
- if i == 1 then
- pad3c = choosing
- elseif i == 2 then
- pad2c = choosing
- elseif i == 3 then
- pad1c = choosing
- end
- else
- mapselect = false
- choosemap()
- break
- end
- end
- if mapselect then
- countdown()
- end
- end
- --Basically the start countdown--
- function countdown()
- gamesign.Text.StatusChange.Text = "Choosing Map!"
- local countdownnumber2 = countdownnumber
- for i = 1, countdownnumber do
- gamesign.Text.StatusChange.Text = ("Choosing Map! ".. countdownnumber2)
- countdownnumber2 = countdownnumber2 - 1
- wait(1)
- end
- gamesign.Text.StatusChange.Text = ("Game in progress!")
- mapselect = false
- playing = true
- loadmap() --Calls Loadmap
- end
- --Load map and updates votes--
- function loadmap()
- local choice = nil
- if pad1 > pad2 and pad1 > pad3 and (choice == nil) then
- choice = pad1c
- elseif pad2 > pad1 and pad2 > pad3 and (choice == nil) then
- choice = pad2c
- elseif pad3 > pad1 and pad3 > pad2 and (choice == nil) then
- choice = pad3c
- elseif pad1 == pad2 and pad1 == pad3 and pad2 == pad3 and (choice == nil) then
- local choices = {pad1c, pad2c, pad3c}
- choice = (choices[math.random(1,3)])
- elseif pad1 == pad2 and pad1 > pad3 and pad2 > pad3 and (choice == nil) then
- local choices = {pad1c, pad2c}
- choice = (choices[math.random(1, 2)])
- elseif pad2 == pad3 and pad2 > pad1 and pad3 > pad1 and (choice == nil) then
- local choices = {pad2c, pad3c}
- choice = (choices[math.random(1, 2)])
- end
- Workspace.Island.MapName.Text = tostring(choice)
- if choice == "Bricks" then
- for i,v in pairs(Workspace.PlayArea.Maps.Bricks:GetChildren()) do -- ERRORS
- v.Opacity = 255
- v.CanCollide = true
- end
- elseif choice == "Sand" then
- for i,v in pairs(Workspace.PlayArea.Maps.Sand:GetChildren()) do -- ERRORS
- v.Opacity = 255
- v.CanCollide = true
- end
- elseif choice == "Slim" then
- for i,v in pairs(Workspace.PlayArea.Maps.Slim:GetChildren()) do -- ERRORS
- v.Opacity = 255
- v.CanCollide = true
- end
- elseif choice == "Squares" then
- for i,v in pairs(Workspace.PlayArea.Maps.Squares:GetChildren()) do -- ERRORS
- v.Opacity = 255
- v.CanCollide = true
- end
- elseif choice == "FloodedTown" then
- for i,v in pairs(Workspace.PlayArea.Maps.FloodedTown:GetChildren()) do -- ERRORS
- v.Opacity = 255
- v.CanCollide = true
- end
- end
- resetpads("Game in progress!") --Changes pads text to message
- wait(3)
- teleportmap() --Teleporting players to map
- updatevotes() --Updates votes to 0
- end
- --Teleporting players to map--
- function teleportmap()
- local whichspawn = 1
- local players = Players.GetPlayers()
- for index, player in pairs(players) do
- if player.Health >= 1 then
- player.Position = Workspace.PlayArea.Spawns:FindFirstChild("Spawn"..whichspawn).Position
- Leaderboard.SetPlayerTeam(player, "Playing")
- table.insert(currentlyplaying, player.Username)
- end
- whichspawn = whichspawn + 1
- end
- startgame()
- end
- --Resets pads to message--
- function resetpads(message)
- for i,v in pairs(Workspace.GamePads:GetChildren()) do
- if v.Name == "GamePad1" or v.Name == "GamePad2" or v.Name == "GamePad3" then
- v:FindFirstChild("MapName").Text = (message)
- else
- resetpads()
- end
- end
- end
- function resetpos(player)
- for i,v in pairs(Players.GetPlayers()) do
- if Leaderboard.GetPlayerTeam(v) == "Playing" then
- if player.Health > 0 then
- player.Position = Vector3.new(3.16, 5, 16.9)
- end
- end
- end
- end
- --Resets all--
- function resetwhole()
- currentlyplaying = {}
- local players = Players.GetPlayers()
- for index, player in pairs(players) do
- resetpos(player)
- Leaderboard.SetPlayerTeam(player, "Spectating")
- end
- for i,v in pairs(Workspace.PlayArea.PlatformStart:GetChildren()) do
- v.Opacity = 255
- v.CanCollide = true
- end
- Workspace.PlayArea.HowLong.Text = "Choosing Map!"
- pad1c = 0 --Pad1 Votes
- pad2c = 0 --Pad2 Votes
- pad3c = 0 --Pad3 Votes
- resetmap()
- pad1 = 0
- pad1players = {}
- pad2 = 0
- pad2players = {}
- pad3 = 0
- pad3players = {}
- playing = false
- playerteleporting = 0
- updatevotes()
- checking()
- end
- function checkingplaying()
- local found = false
- for i,v in pairs(Players.GetPLayers()) do
- if Leaderboard.GetPlayerTeam(v) == "Playing" then
- found = true
- break
- end
- end
- return(found)
- end
- --When the game is running--
- function startgame()
- local countdownnumber3 = 0
- for i = 1, (roundtime * 10) do
- if playing then
- if i >= 10 then
- Workspace.PlayArea.HowLong.Text = tostring(countdownnumber3):sub(1, 4)
- else
- Workspace.PlayArea.HowLong.Text = tostring(countdownnumber3):sub(1, 3)
- end
- if checkingplaying() then
- countdownnumber3 = countdownnumber3 + 0.1
- wait(0.08)
- else
- break
- end
- else
- break
- end
- if i > 100 and i < 110 then
- for i,v in pairs(Workspace.PlayArea.PlatformStart:GetChildren()) do
- v.Opacity = 100
- v.CanCollide = false
- end
- end
- end
- wait(1)
- Workspace.PlayArea.HowLong.Text = "Game Over!"
- resetwhole()
- end
- --Clears the play area--
- function resetmap()
- local placement = Workspace.PlayArea.Maps
- resetmap2(placement.Bricks)
- resetmap2(placement.Sand)
- resetmap2(placement.Slim)
- resetmap2(placement.Squares)
- resetmap2(placement.FloodedTown)
- end
- function resetmap2(map)
- for i,v in pairs (map:GetChildren()) do
- v.Opacity = 0
- v.CanCollide = false
- end
- end
- function checkplayers(looking)
- if #currentlyplaying >= 1 then
- for i,v in pairs(currentlyplaying) do
- if v == looking then
- table.remove(currentlyplaying, i)
- break
- end
- end
- end
- if not currentplaying then
- resetwhole()
- end
- end
- --Checking the playercount, and min player--
- function checking()
- if playing == false and playercount >= playerstostart then
- gamesign.Text.StatusChange.Text = "Choosing Map!"
- choosemap()
- --Not Playing with not meeting Player requirement--
- else if playing == false and playercount < playerstostart then
- gamesign.Text.StatusChange.Text = "Waiting For Players!"
- resetpads("Waiting for players")
- end
- end
- end
- --Updates the gamepad text for votes--
- function updatevotes()
- Workspace.GamePads.GamePad1.Votes.Text = pad1
- Workspace.GamePads.GamePad2.Votes.Text = pad2
- Workspace.GamePads.GamePad3.Votes.Text = pad3
- end
- --------------------------------------------------------------------------
- --Game Sign Status--
- Players.PlayerJoined:Connect(function(Player)
- Leaderboard.SetPlayerTeam(Player, "Spectating")
- getplayercount()
- --Checking for game off and playercount.
- checking()
- end)
- Players.PlayerLeft:Connect(function(Player)
- getplayercount()
- --Checking for game off and playercount.
- checking()
- end)
- function getplayercount()
- local playercount2 = 0
- local players = Players.GetPlayers()
- for index, player in pairs(players) do
- playercount2 = playercount2 + 1
- end
- playercount = playercount2
- end
- --------------------------------------------------------------------------
- --Pad1--
- Workspace.Sensors.Sensor1.Touched:Connect(function(hit)
- if hit:isA("Player") and mapselect == true then
- hit.Position = Vector3.new(math.random(0, 6.5), 1, 14)
- local found = false
- if found == false then
- for i,v in pairs(pad1players) do
- if hit.Username == v then
- found = true
- break
- end
- end
- end
- if found == false then
- for i,v in pairs(pad2players) do
- if hit.Username == v then
- found = true
- pad2 = pad2 - 1
- table.remove(pad2players, i)
- table.insert(pad1players, hit.Username)
- pad1 = pad1 + 1
- break
- end
- end
- end
- if found == false then
- for i,v in pairs(pad3players) do
- if hit.Username == v then
- found = true
- pad3 = pad3 - 1
- table.remove(pad3players, i)
- table.insert(pad1players, hit.Username)
- pad1 = pad1 + 1
- break
- end
- end
- end
- if found == false then
- table.insert(pad1players, hit.Username)
- pad1 = pad1 + 1
- end
- updatevotes()
- wait(0.1)
- end
- end)
- --Pad2--
- Workspace.Sensors.Sensor2.Touched:Connect(function(hit)
- if hit:isA("Player") and mapselect == true then
- hit.Position = Vector3.new(math.random(0, 6.5), 1, 14)
- local found = false
- if found == false then
- for i,v in pairs(pad1players) do
- if hit.Username == v then
- found = true
- pad1 = pad1 - 1
- table.remove(pad1players, i)
- table.insert(pad2players, hit.Username)
- pad2 = pad2 + 1
- break
- end
- end
- end
- if found == false then
- for i,v in pairs(pad2players) do
- if hit.Username == v then
- found = true
- break
- end
- end
- end
- if found == false then
- for i,v in pairs(pad3players) do
- if hit.Username == v then
- found = true
- pad3 = pad3 - 1
- table.remove(pad3players, i)
- table.insert(pad2players, hit.Username)
- pad2 = pad2 + 1
- break
- end
- end
- end
- if found == false then
- table.insert(pad2players, hit.Username)
- pad2 = pad2 + 1
- end
- updatevotes()
- wait(0.1)
- end
- end)
- --Pad3--
- Workspace.Sensors.Sensor3.Touched:Connect(function(hit)
- if hit:isA("Player") and mapselect == true then
- hit.Position = Vector3.new(math.random(0, 6.5), 1, 14)
- local found = false
- if found == false then
- for i,v in pairs(pad1players) do
- if hit.Username == v then
- found = true
- pad1 = pad1 - 1
- table.remove(pad1players, i)
- table.insert(pad3players, hit.Username)
- pad3 = pad3 + 1
- break
- end
- end
- end
- if found == false then
- for i,v in pairs(pad2players) do
- if hit.Username == v then
- found = true
- pad2 = pad2 - 1
- table.remove(pad2players, i)
- table.insert(pad3players, hit.Username)
- pad3 = pad3 + 1
- break
- end
- end
- end
- if found == false then
- for i,v in pairs(pad3players) do
- if hit.Username == v then
- found = true
- break
- end
- end
- end
- if found == false then
- table.insert(pad3players, hit.Username)
- pad3 = pad3 + 1
- end
- updatevotes()
- wait(0.1)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement