Create zombie spawner

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Code:
variables:
  {voting} = false
  {forest_votes} = 0
  {town_votes} = 0
 
  {pvp_votes} = 0
  {nopvp_votes} = 0
 
  {selected_map} = "unknown"
  {modifier} = "unknown"
 
command /votingdeny:
    executable by: op
    permission: votingdeny.command
    trigger:
        set {voting} to false
        send "Voting has been ended by an operator (debug)" to players

options:
    block: black concrete powder

local function zombieLoop():
    set {_loopcount} to {zombiespawningloop}
    while {_loopcount} is {zombiespawningloop}:
        loop {zombiespawnblocks::*}:
            set {_loc} to location of block above loop-value
            spawn a zombie at {_loc}
        wait 5 second

function gracePeriod():
    send "" to players
    send "&a&l&nROUND STARTED" to players
    send "" to players
    send "&7Grace period for &e30s&7!" to players
    send "" to players
    
    execute console command "rg flag -w 'zombie' %{selected_map}% pvp deny"
    
    wait 3 seconds

    play sound "minecraft:entity.experience_orb.pickup" to players

    if {modifier} = "pvp":
        send "" to players
        send "&a&l&nGAME MODIFIER" to players
        send "" to players
        send "&7The selected modifier is &c&lPVP&7!" to players
        send "" to players
    if {modifier} = "nopvp":
        send "" to players
        send "&a&l&nGAME MODIFIER" to players
        send "" to players
        send "&7The selected modifier is &a&lNO PVP&7!" to players
        send "" to players
    
    wait 27 seconds
            
    play sound "minecraft:entity.ender_dragon.growl" to players

    if {modifier} = "pvp":
        execute console command "rg flag -w 'zombie' %{selected_map}% pvp allow"

        send "" to players
        send "&c&l&nPVP ON + ZOMBIES SPAWNING" to players
        send "" to players
        send "&7Grace period has ended!" to players
        send "" to players
    if {modifier} = "nopvp":
        send "" to players
        send "&c&l&nZOMBIES SPAWNING" to players
        send "" to players
        send "&7Grace period has ended!" to players
        send "" to players

        if {selected_map} = "forest":
            delete {zombiespawnblocks::*}
            loop all blocks within location(535, -41, 66, world "zombie") and location(380,-63, -68, world "zombie"):

            if loop-block is {@block}:
                add loop-block to {zombiespawnblocks::*}

                add 1 to {zombiespawningloop}
                zombieLoop()

        if {selected_map} = "town":
            send "idk" to players

function teleport():
    execute console command "time set 15600"
    execute console command "timer time set 1m"
    execute console command "timer start"
    execute console command "team join playing @a"
    execute console command "kill @e[type=item]"
    
    heal players by 10 hearts
    execute console command "effect clear @a minecraft:saturation"

    gracePeriod()
    
    if {selected_map} = "forest":
        teleport all players to location(439.5, -60, -11.5, world "zombie")
        execute console command "reloadlootforest"
        
        play sound "minecraft:entity.ender_dragon.growl" to players
    if {selected_map} = "town":
        teleport all players to location(-406.5, -60, 3.5, world "zombie")
        execute console command "reloadloottown"
        
        play sound "minecraft:entity.ender_dragon.growl" to players
        
function vote(p: player):
    set metadata tag "voteGUI" of {_p} to chest inventory with 3 rows named "&8Vote for a map!"
    set slot 0 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 1 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 2 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 3 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 4 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 5 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 6 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 7 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 8 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 9 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 10 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 11 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 12 of metadata tag "voteGUI" of {_p} to oak sapling named "&2&lForest" with lore "&7A dark forest filled with uninhabited buildings."
    set slot 13 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 14 of metadata tag "voteGUI" of {_p} to spruce stairs named "&9&lTown" with lore "&7A chaotic abandonded town with fire and destruction."
    set slot 15 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 16 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 17 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 18 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 19 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 20 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 21 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 22 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 23 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 24 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 25 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 26 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 27 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    open (metadata tag "voteGUI" of {_p}) to {_p}

function modifier(p: player):
    set metadata tag "modifierGUI" of {_p} to chest inventory with 3 rows named "&8Vote for a modifier!"
    set slot 0 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 1 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 2 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 3 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 4 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 5 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 6 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 7 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 8 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 9 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 10 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 11 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 12 of metadata tag "modifierGUI" of {_p} to iron sword named "&c&lPVP" with lore "&7Combat other players and zombies."
    set slot 13 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 14 of metadata tag "modifierGUI" of {_p} to barrier named "&a&lNo PVP" with lore "&7Combat zombies with other players"
    set slot 15 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 16 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 17 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 18 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 19 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 20 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 21 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 22 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 23 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 24 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 25 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 26 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 27 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    open (metadata tag "modifierGUI" of {_p}) to {_p}

function start():
    if {voting} is true:
        loop all players:
            vote(loop-player)

        send "" to players
        send "&a&l&nNEW ROUND" to players
        send "" to players
        send "&7Map voting has begun! &e15s" to players
        send "" to players

        wait 600 tick

        close inventory of players
        play sound "minecraft:entity.experience_orb.pickup" to players

        send "" to players
        send "&a&l&nVOTING RESULTS" to players
        send "" to players
        send "&2&lForest &7- &f%{forest_votes}% &7votes" to players
        send "&9&lTown &7- &f%{town_votes}% &7votes" to players
        send "" to players

        wait 60 tick

        loop all players:
            modifier(loop-player)

        send "" to players
        send "&a&l&nMODIFIER VOTING" to players
        send "" to players
        send "&7Vote for a game modifier! &e15s" to players
        send "" to players

        wait 600 tick

        close inventory of players
        play sound "minecraft:entity.experience_orb.pickup" to players

        send "" to players
        send "&a&l&nVOTING RESULTS" to players
        send "" to players
        send "&c&lPVP &7- &f%{pvp_votes}% &7votes" to players
        send "&a&lNo PVP &7- &f%{nopvp_votes}% &7votes" to players
        send "" to players

        wait 60 tick

        play sound "minecraft:entity.ender_pearl.throw" to players
        send "" to players
        send "&a&l&nSTARTING ROUND" to players
        send "" to players
        send "&7Round begins in &e3s" to players

        wait 20 tick
        
        send "&7Round begins in &e2s" to players
        play sound "minecraft:entity.ender_pearl.throw" to players

        wait 20 tick
        
        send "&7Round begins in &e1s" to players
        play sound "minecraft:entity.ender_pearl.throw" to players

        wait 20 tick

        set {voting} to false
        execute console command "effect give @a minecraft:blindness 2"

        if {pvp_votes} is greater than {nopvp_votes}:
            set {modifier} to "pvp"
        if {nopvp_votes} is greater than {pvp_votes}:
            set {selected_map} to "nopvp"
        else:
            {random_number} = 0
            set {random_number} to a random integer between 1 and 2
            
            if {random_number} = 1:
                set {modifier} to "pvp"
            if {random_number} = 2:
                set {modifier} to "nopvp"

        set {pvp_votes} to 0
        set {nopvp_votes} to 0
        
        if {forest_votes} >= {town_votes}:
            set {selected_map} to "forest"

            teleport()
        if {town_votes} >= {forest_votes}:
            set {selected_map} to "town"

            teleport()
        else:
            {random_number} = 0
            set {random_number} to a random integer between 1 and 2

            if {random_number} = 1:
                set {selected_map} to "forest"
            else if {random_number} = 2:
                set {selected_map} to "town"

            teleport()

        set {forest_votes} to 0
        set {town_votes} to 0

on inventory click:
    if event-inventory = (metadata tag "voteGUI" of player):
        cancel event
        
        if index of event-slot is 12:
            close inventory of player
            add 1 to {forest_votes}
            send "&f%player% has voted &2&lForest&f!" to players
            play sound "minecraft:entity.experience_orb.pickup" to players
        else if index of event-slot is 14:
            close inventory of player
            add 1 to {town_votes}
            send "&f%player% has voted &9&lTown&f!" to players
            play sound "minecraft:entity.experience_orb.pickup" to player
    if event-inventory = (metadata tag "modifierGUI" of player):
        cancel event
        
        if index of event-slot is 12:
            close inventory of player
            add 1 to {pvp_votes}
            send "&f%player% has voted &c&lPVP&f!" to players
            play sound "minecraft:entity.experience_orb.pickup" to players
        else if index of event-slot is 14:
            close inventory of player
            add 1 to {nopvp_votes}
            send "&f%player% has voted &a&lNO PVP&f!" to players
            play sound "minecraft:entity.experience_orb.pickup" to player
on join:
    set join message to "&8[&a✔&8] &f%player%"

    execute console command "clear %player%"
    execute console command "effect give %player% minecraft:saturation infinite"

    set {spawn} to location(-4.5, -55.5, 1.5)
    set pitch of {spawn} to 0
    set yaw of {spawn} to -180
    teleport player to {spawn}

    if amount of all players is equal to 1:
        if {voting} is false:
            execute console command "timer time set 1m"
            execute console command "timer pause"

            execute console command "team add playing"
            wait 40 ticks
            
            set {voting} to true
            start()
    else:
        wait 40 ticks
        vote(player)
on quit:
    set quit message to "&8[&c❌&8] &f%player%"

    if amount of all players is equal to 0:
        execute console command "team remove playing"
        set {voting} to false

        set {forest_votes} to 0
        set {town_votes} to 0
 
        set {pvp_votes} to 0
        set {nopvp_votes} to 0

on respawn:
    execute console command "team leave %player%"
    send title "&c&lYOU DIED!" with subtitle "&7Game over!" to player for 5 seconds

on right click on iron door:
    if held item of player is tripwire hook:
        cancel event
        play sound "minecraft:entity.zombie.attack_iron_door" at event-block to player
        send "&e%player% has opened a vault!" to players
        send title "&a&lVAULT OPENED!" with subtitle "&7You opened a vault!" to player for 5 seconds
        
        if block under event-block is iron door:
            set block under event-block to air
        else:
            set event-block to air
 
Last edited:
Python:
        if {selected_map} = "forest":
            delete {zombiespawnblocks::*}
            loop all blocks within location(535, -41, 66, world "zombie") and location(380,-63, -68, world "zombie"):
                if loop-block is {@block}:
                    add loop-block to {zombiespawnblocks::*}

                    add 1 to {zombiespawningloop}
                    zombieLoop()

        if {selected_map} = "town":
            send "idk" to players

You didn't change the part of the code that i sent you. Please make sure about changes and test it. This code is the true one. Just copy it all and paste from line 75.
 
Code:
variables:
  {voting} = false
  {spawning_zombies} = false

  {forest_votes} = 0
  {town_votes} = 0
 
  {pvp_votes} = 0
  {nopvp_votes} = 0
 
  {selected_map} = "unknown"
  {modifier} = "unknown"

command /parkour:
    executable by: players
    permission: parkour.command
    trigger:
        set {spawn} to location(-0.5, -55, 1.5)
        set pitch of {spawn} to 0
        set yaw of {spawn} to -90
        teleport player to {spawn}
        send "&aTeleported to parkour!" to player
        play sound "minecraft:entity.experience_orb.pickup" to players

command /votingdeny:
    executable by: op
    permission: votingdeny.command
    trigger:
        set {voting} to false
        send "Voting has been ended by an operator (debug)" to players

options:
    block: black concrete powder

function zombieSpawn():
    if {selected_map} = "forest":
        delete {zombiespawnblocks::*}
        loop all blocks within location(535, -41, 66, world "zombie") and location(380,-63, -68, world "zombie"):
            if loop-block is {@block}:
                add loop-block to {zombiespawnblocks::*}
                add 1 to {zombiespawningloop}
                zombieLoop()

local function zombieLoop():
    if {spawning_zombies} = true:
        set {_loopcount} to {zombiespawningloop}
        while {_loopcount} is {zombiespawningloop}:
            loop {zombiespawnblocks::*}:
                set {_loc} to location of block above loop-value
                spawn a zombie at {_loc}
            wait 5 seconds

function gracePeriod():
    send "" to players
    send "&a&l&nROUND STARTED" to players
    send "" to players
    send "&7Grace period for &e30s&7!" to players
    send "" to players
    
    execute console command "rg flag -w 'zombie' %{selected_map}% pvp deny"
    
    wait 3 seconds

    play sound "minecraft:entity.experience_orb.pickup" to players

    if {modifier} = "pvp":
        send "" to players
        send "&a&l&nGAME MODIFIER" to players
        send "" to players
        send "&7The selected modifier is &c&lPVP&7!" to players
        send "" to players
    if {modifier} = "nopvp":
        send "" to players
        send "&a&l&nGAME MODIFIER" to players
        send "" to players
        send "&7The selected modifier is &a&lNO PVP&7!" to players
        send "" to players
    
    wait 27 seconds
            
    play sound "minecraft:entity.ender_dragon.growl" to players

    set {spawning_zombies} to true
    zombieSpawn()

    if {modifier} = "pvp":
        execute console command "rg flag -w 'zombie' %{selected_map}% pvp allow"

        send "" to players
        send "&c&l&nPVP ON + ZOMBIES SPAWNING" to players
        send "" to players
        send "&7Grace period has ended!" to players
        send "" to players
    if {modifier} = "nopvp":
        send "" to players
        send "&c&l&nZOMBIES SPAWNING" to players
        send "" to players
        send "&7Grace period has ended!" to players
        send "" to players
        
    wait 390 seconds

    set {spawning_zombies} to false

function teleport():
    execute console command "time set 15600"
    execute console command "timer time set 1m"
    execute console command "timer start"
    execute console command "team join playing @a"
    execute console command "kill @e[type=item]"
    
    heal players by 10 hearts
    execute console command "effect clear @a minecraft:saturation"

    gracePeriod()
    
    if {selected_map} = "forest":
        teleport all players to location(439.5, -60, -11.5, world "zombie")
        execute console command "reloadlootforest"
        
        play sound "minecraft:entity.ender_dragon.growl" to players
    if {selected_map} = "town":
        teleport all players to location(-406.5, -60, 3.5, world "zombie")
        execute console command "reloadloottown"
        
        play sound "minecraft:entity.ender_dragon.growl" to players
        
function vote(p: player):
    set metadata tag "voteGUI" of {_p} to chest inventory with 3 rows named "&8Vote for a map!"
    set slot 0 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 1 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 2 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 3 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 4 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 5 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 6 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 7 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 8 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 9 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 10 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 11 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 12 of metadata tag "voteGUI" of {_p} to oak sapling named "&2&lForest" with lore "&7A dark forest filled with uninhabited buildings."
    set slot 13 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 14 of metadata tag "voteGUI" of {_p} to spruce stairs named "&9&lTown" with lore "&7A chaotic abandonded town with fire and destruction."
    set slot 15 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 16 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 17 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 18 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 19 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 20 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 21 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 22 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 23 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 24 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 25 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 26 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    set slot 27 of metadata tag "voteGUI" of {_p} to black stained glass pane named " "
    open (metadata tag "voteGUI" of {_p}) to {_p}

function modifier(p: player):
    set metadata tag "modifierGUI" of {_p} to chest inventory with 3 rows named "&8Vote for a modifier!"
    set slot 0 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 1 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 2 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 3 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 4 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 5 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 6 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 7 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 8 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 9 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 10 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 11 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 12 of metadata tag "modifierGUI" of {_p} to iron sword named "&c&lPVP" with lore "&7Combat other players and zombies."
    set slot 13 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 14 of metadata tag "modifierGUI" of {_p} to barrier named "&a&lNo PVP" with lore "&7Combat zombies with other players"
    set slot 15 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 16 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 17 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 18 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 19 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 20 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 21 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 22 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 23 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 24 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 25 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 26 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    set slot 27 of metadata tag "modifierGUI" of {_p} to black stained glass pane named " "
    open (metadata tag "modifierGUI" of {_p}) to {_p}

function start():
    if {voting} is true:
        loop all players:
            vote(loop-player)

        send "" to players
        send "&a&l&nNEW ROUND" to players
        send "" to players
        send "&7Map voting has begun! &e15s" to players
        send "" to players

        wait 600 tick

        close inventory of players
        play sound "minecraft:entity.experience_orb.pickup" to players

        send "" to players
        send "&a&l&nVOTING RESULTS" to players
        send "" to players
        send "&2&lForest &7- &f%{forest_votes}% &7votes" to players
        send "&9&lTown &7- &f%{town_votes}% &7votes" to players
        send "" to players

        wait 60 tick

        loop all players:
            modifier(loop-player)

        send "" to players
        send "&a&l&nMODIFIER VOTING" to players
        send "" to players
        send "&7Vote for a game modifier! &e15s" to players
        send "" to players

        wait 600 tick

        close inventory of players
        play sound "minecraft:entity.experience_orb.pickup" to players

        send "" to players
        send "&a&l&nVOTING RESULTS" to players
        send "" to players
        send "&c&lPVP &7- &f%{pvp_votes}% &7votes" to players
        send "&a&lNo PVP &7- &f%{nopvp_votes}% &7votes" to players
        send "" to players

        wait 60 tick

        play sound "minecraft:entity.ender_pearl.throw" to players
        send "" to players
        send "&a&l&nSTARTING ROUND" to players
        send "" to players
        send "&7Round begins in &e3s" to players

        wait 20 tick
        
        send "&7Round begins in &e2s" to players
        play sound "minecraft:entity.ender_pearl.throw" to players

        wait 20 tick
        
        send "&7Round begins in &e1s" to players
        play sound "minecraft:entity.ender_pearl.throw" to players

        wait 20 tick

        set {voting} to false
        execute console command "effect give @a minecraft:blindness 2"

        if {pvp_votes} is greater than {nopvp_votes}:
            set {modifier} to "pvp"
        if {nopvp_votes} is greater than {pvp_votes}:
            set {modifier} to "nopvp"
        else:
            {random_number} = 0
            set {random_number} to a random integer between 1 and 2
            
            if {random_number} = 1:
                set {modifier} to "pvp"
            if {random_number} = 2:
                set {modifier} to "nopvp"

        set {pvp_votes} to 0
        set {nopvp_votes} to 0
        
        if {forest_votes} >= {town_votes}:
            set {selected_map} to "forest"

            teleport()
        if {town_votes} >= {forest_votes}:
            set {selected_map} to "town"

            teleport()
        else:
            {random_number} = 0
            set {random_number} to a random integer between 1 and 2

            if {random_number} = 1:
                set {selected_map} to "forest"
            else if {random_number} = 2:
                set {selected_map} to "town"

            teleport()

        set {forest_votes} to 0
        set {town_votes} to 0

on inventory click:
    if event-inventory = (metadata tag "voteGUI" of player):
        cancel event
        
        if index of event-slot is 12:
            close inventory of player
            add 1 to {forest_votes}
            send "&f%player% has voted &2&lForest&f!" to players
            play sound "minecraft:entity.experience_orb.pickup" to players
        else if index of event-slot is 14:
            close inventory of player
            add 1 to {town_votes}
            send "&f%player% has voted &9&lTown&f!" to players
            play sound "minecraft:entity.experience_orb.pickup" to player
    if event-inventory = (metadata tag "modifierGUI" of player):
        cancel event
        
        if index of event-slot is 12:
            close inventory of player
            add 1 to {pvp_votes}
            send "&f%player% has voted &c&lPVP&f!" to players
            play sound "minecraft:entity.experience_orb.pickup" to players
        else if index of event-slot is 14:
            close inventory of player
            add 1 to {nopvp_votes}
            send "&f%player% has voted &a&lNO PVP&f!" to players
            play sound "minecraft:entity.experience_orb.pickup" to player
on join:
    set join message to "&8[&a✔&8] &f%player%"

    execute console command "clear %player%"
    execute console command "effect give %player% minecraft:saturation infinite"

    set {spawn} to location(-4.5, -55.5, 1.5)
    set pitch of {spawn} to 0
    set yaw of {spawn} to -180
    teleport player to {spawn}

    if amount of all players is equal to 1:
        if {voting} is false:
            execute console command "timer time set 1m"
            execute console command "timer pause"

            execute console command "team add playing"
            wait 40 ticks
            
            set {voting} to true
            start()
    else:
        wait 40 ticks
        vote(player)
on quit:
    set quit message to "&8[&c❌&8] &f%player%"

    if amount of all players is equal to 0:
        execute console command "team remove playing"
        set {voting} to false

        set {forest_votes} to 0
        set {town_votes} to 0
 
        set {pvp_votes} to 0
        set {nopvp_votes} to 0

on respawn:
    execute console command "team leave %player%"
    send title "&c&lYOU DIED!" with subtitle "&7Game over!" to player for 5 seconds

on right click on iron door:
    if held item of player is tripwire hook:
        cancel event
        play sound "minecraft:entity.zombie.attack_iron_door" at event-block to player
        send "&e%player% has opened a vault!" to players
        send title "&a&lVAULT OPENED!" with subtitle "&7You opened a vault!" to player for 5 seconds
        
        if block under event-block is iron door:
            set block under event-block to air
        else:
            set event-block to air