Can someone add a map changer to this? [closed]
wait(1);
system = script.Parent
is_playing = system.Playing
stage = system.Stage
weapons = game.Workspace.Weapons
hum_team = game.Teams["Humans"]
zom_team = game.Teams["Zombies"]
msg = nil
hint = nil
playing = false
interrupted = false
minutes = 0
seconds = 0
function displayHint(text)
if(hint==nil)then
hint = Instance.new("Hint")
hint.Text = text
hint.Parent = game.Workspace
else
hint.Text = text
end
end
function removeHint()
if(hint~=nil)then hint:remove() hint = nil end
end
function displayMsg(text)
if(msg==nil)then
msg = Instance.new("Message")
msg.Text = text
msg.Parent = game.Workspace
else
msg.Text = text
end
end
function removeMsg()
if(msg~=nil)then msg:remove() msg = nil end
end
function giveWeapons()
local player = game.Players:GetChildren()
if(#player>0)then
for p = 1, #player do
if(player[p].TeamColor==hum_team.TeamColor)then
shared["Weps"]["Pistol"]:Clone().Parent = player[p].Backpack
end
end
end
end
function killPlayers()
local player = game.Players:GetChildren()
if(#player>0)then
for p = 1, #player do
if(player[p].Character~=nil)then
local h = player[p].Character:FindFirstChild("Humanoid")
if(h.Health>0)then
player[p].Character.Humanoid.Health = 0
else
if(player[p]:FindFirstChild("Dead")~=nil)then
player[p].Dead.Value = false
player[p].Class.Value = "Zombie"
player[p].TeamColor = hum_team.TeamColor
end
end
end
end
end
end
function resetPlayers()
local player = game.Players:GetChildren()
if(#player>0)then
for p = 1, #player do
if(player[p]:FindFirstChild("Dead")~=nil)then
player[p].Dead.Value = false
player[p].Class.Value = "Zombie"
player[p].TeamColor = hum_team.TeamColor
end
end
end
end
function countPlayers()
local count = 0
local player = game.Players:GetChildren()
if(#player>0)then
for p = 1, #player do
if(player[p].Character~=nil)then
count = count +1
end
end
end
return count
end
function countPlayersInTeam(team)
local team_count = 0
local player = game.Players:GetChildren()
if(#player>0)then
for p = 1, #player do
if(player[p].TeamColor==team.TeamColor)then
team_count = team_count +1
end
end
end
return team_count
end
function assignZombies(amount)
local valid_players = {}
local player = game.Players:GetChildren()
if(#player>0)then
for p = 1, #player do
if(player[p].TeamColor==hum_team.TeamColor)and
(player[p].Character~=nil)then
table.insert(valid_players,player[p])
end
end
end
if(#valid_players>amount)then
while(amount>0)do
local rand = math.random(1,#valid_players)
local chosen = valid_players[rand]
chosen.TeamColor = zom_team.TeamColor
chosen.Character.Humanoid.Health = 0
table.remove(valid_players,rand)
amount = amount -1
end
end
end
function countDown()
seconds = seconds -1
if(seconds<0)then
minutes = minutes -1
seconds = 59
if(minutes<0)then playing = false return true end
end
return false
end
function playZombies()
if(countPlayers()<=3)then
assignZombies(1)
elseif(countPlayers()<=6)then
assignZombies(2)
else
assignZombies(3)
end
is_playing.Value = true
Game.workspace.Unlocked:Play()
displayMsg("Human team, Fight the zombies for 15 minutes and avoid infection.")
wait(1);
for i,v in ipairs(game.Players:GetChildren()) do -- Should fix zombies not morphing.
if v.TeamColor == zom_team.TeamColor then
v.Character:BreakJoints();
end
end
delay(5,function () giveWeapons(); end); -- Wait for respawns?
delay(5,removeMsg)
interrupted = false
playing = true
minutes = 12
seconds = 59
while(playing==true)and(countDown()==false)do
local humans = countPlayersInTeam(hum_team)
local zombies = countPlayersInTeam(zom_team)
if(minutes==9)and(seconds==59)then
stage.Value = 2
Game.workspace.Unlocked:Play()
displayMsg("FAST zombie is NOW UNLOCKED! say '/fastzombie' to become a fast zombie!")
delay(10,removeMsg)
elseif(minutes==4)and(seconds==59)then
stage.Value = 3
Game.workspace.Unlocked:Play()
displayMsg("KamiZombie is NOW UNLOCKED! say '/kamizombie' to become a kamizombie!")
delay(10,removeMsg)
elseif(minutes==7)and(seconds==25)then
stage.Value = 4
Game.workspace.Unlocked:Play()
displayMsg("Ghost ZOMBIE is NOW UNLOCKED! say '/ghostzombie' to become a Ghost!")
delay(10,removeMsg)
elseif(minutes==6)and(seconds==25)then
stage.Value = 5
Game.workspace.Unlocked:Play()
displayMsg("Fast GHOST Zombie is NOW UNLOCKED! say '/fastghostzombie' to become a FastGhostzombie!")
delay(10,removeMsg)
elseif(minutes==2)and(seconds==25)then
stage.Value = 6
Game.workspace.Unlocked:Play()
displayMsg("ZOMBIE BOSS is NOW UNLOCKED! say '/zombieboss' to become a BOSS!")
delay(10,removeMsg)
end
if(seconds<10)then
displayHint("Humans left: "..humans.." | Time left: "..minutes..":0"..seconds.." | Zombies: "..zombies)
else
displayHint("Humans left: "..humans.." | Time left: "..minutes..":"..seconds.." | Zombies: "..zombies)
end
if(zombies==0)then -- Zombies left the game? Try to assign another to keep the game running!
if(countPlayers()>=2)then
if(countPlayers()<=3)then
assignZombies(1)
elseif(countPlayers()<=6)then
assignZombies(2)
else
assignZombies(3)
end
else
interrupted = true
break
end
end
if(humans==0)then
break
end
wait(1)
end
stage.Value = 1
removeHint()
if(interrupted==true)then
Game.workspace.SENSATIONAL:Play()
displayMsg("There are not enough players to continue the game...")
else
if(playing==false)then
Game.workspace.SENSATIONAL:Play()
displayMsg("Humans have outlasted the zombies!")
else
Game.workspace.Rawr:Play()
displayMsg("Zombies have infected everyone!")
end
end
is_playing.Value = false
killPlayers()
wait(5)
resetPlayers()
removeMsg()
end
while true do
wait(3)
resetPlayers()
if(countPlayers()>=2)then
removeMsg()
playZombies()
else
displayMsg("There are not enough players to continue the game...")
end
end
Closed as Not Constructive by theking48989987 and whenallthepigsfly
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?