Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone add a map changer to this?

Asked by 7 years ago

How do i add a map changer to this? and when the players all die the map changes to the new map and spawns players on their correct team?

Wait(1) local System = script.Parent local Playing = System:FindFirstChild('Playing') local Stage = System:FindFirstChild('Stage') local Weapon = Game.Lighting:FindFirstChild('Pistol') local Humans = Game.Teams:FindFirstChild('Humans') local Zombies = Game.Teams:FindFirstChild('Zombies') local Message = nil local Hint = nil local vPlaying = false local Interrupted = false local Minutes = 0 local Seconds = 0

local DisplayHint =(function(GameText) if not (Hint) then Hint = Instance.new('Hint') Hint.Text = GameText Hint.Parent = Game.Workspace else Hint.Text = GameText end end)

local RemoveHint =(function() if (Hint) then Hint:remove() Hint = nil end end)

local DisplayMessage =(function(GameText) if not (Message) then Message = Instance.new('Message') Message.Text = GameText Message.Parent = Game.Workspace else Message.Text = GameText end end)

local RemoveMessage =(function() if (Message) then Message:remove() Message = nil end end)

local GiveWeapon =(function() local Player = Game.Players:GetPlayers() if (#Player > 0) then for p = 1,#Player do if (Player[p].TeamColor == Humans.TeamColor) then Weapon:Clone().Parent = Player[p].Backpack end end end end)

local KillPlayers =(function() local Player = Game.Players:GetPlayers() if (#Player > 0) then for p = 1,#Player do if (Player[p].Character) then local Humanoid = Player[p].Character:FindFirstChild('Humanoid') if (Humanoid.Health > 0) then Player[p].Character.Humanoid.Health = 0 else if (Player[p]:FindFirstChild('Dead')) then Player[p]['Dead'].Value = false Player[p]['Class'].Value = 'Zombie' Player[p].TeamColor = Humans.TeamColor end end end end end end)

local ResetPlayers =(function() local Player = Game.Players:GetPlayers() if (#Player > 0) then for p = 1,#Player do if (Player[p]:FindFirstChild('Dead')) then Player[p]['Dead'].Value = false Player[p]['Class'].Value = 'Zombie' Player[p].TeamColor = Humans.TeamColor end end end end)

local CountPlayers =(function() local Count = 0 local Player = Game.Players:GetPlayers() if (#Player > 0)then for p = 1,#Player do if (Player[p].Character) then Count = Count+1 end end end return Count end)

local CountPlayersInTeam =(function(Team) local TeamCount = 0 local Player = Game.Players:GetPlayers() if (#Player > 0) then for p = 1,#Player do if (Player[p].TeamColor == Team.TeamColor) then TeamCount = TeamCount+1 end end end return TeamCount end)

local AssignZombies =(function(Amount) local ValidPlayers = {} local Player = Game.Players:GetPlayers() if (#Player > 0) then for p = 1,#Player do if (Player[p].TeamColor == Humans.TeamColor) and (Player[p].Character) then table.insert(ValidPlayers,Player[p]) end end end if (#ValidPlayers > Amount) then while (Amount > 0) do local Random = math.random(1,#ValidPlayers) local Chosen = ValidPlayers[Random] Chosen.TeamColor = Zombies.TeamColor Chosen.Character['Humanoid'].Health = 0 table.remove(ValidPlayers,Random) Amount = Amount-1 end end end)

local CountDown =(function() Seconds = Seconds - 1 if (Seconds < 0) then Minutes = Minutes - 1 Seconds = 59 if (Minutes < 0) then vPlaying = false return true end end return false end) local PlayZombies =(function() if( CountPlayers() <= 3 )then AssignZombies(1) elseif(CountPlayers() <= 6)then AssignZombies(2) else AssignZombies(3) end Playing.Value = true DisplayMessage('New round, Survive the zombies for 12 minutes!') game.workspace.Rawr:play() for i,v in ipairs(Game.Players:GetPlayers()) do if v.TeamColor == Zombies.TeamColor then -- Should fix zombies not morphing. v.Character:BreakJoints() end end delay(5,function() -- Wait for respawns? GiveWeapon() end) delay(5,RemoveMessage) Interrupted = false vPlaying = true Minutes = 11 Seconds = 59 while (vPlaying == true) and (CountDown() == false) do local vHumans = CountPlayersInTeam(Humans) local vZombies = CountPlayersInTeam(Zombies) if (Minutes == 9) and (Seconds == 59) then Stage.Value = 2 DisplayMessage('FAST zombie is NOW UNLOCKED! say "/fastzombie" to become a fast zombie!') delay(10,RemoveMessage) elseif (Minutes == 4) and (Seconds == 59) then Stage.Value = 3 DisplayMessage('KamiZombie is NOW UNLOCKED! say "/kamizombie" to become a kamizombie!') delay(10,RemoveMessage) end if (Seconds < 10) then DisplayHint('Humans left: '..vHumans..' | Time left: '..Minutes..':0'..Seconds..' | Zombies: '..vZombies) else DisplayHint('Humans left: '..vHumans..' | Time left: '..Minutes..':'..Seconds..' | Zombies: '..vZombies) end if (vZombies == 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 (vHumans == 0) then break end Wait(1) end Stage.Value = 1 RemoveHint() if (Interrupted == true) then DisplayMessage('') -- Everyone left? else if (vPlaying == false) then DisplayMessage('HUMANS HAVE SURVIVED THE VIRUS IS GONE!') game.workspace.SENSATIONAL:play() else DisplayMessage('ZOMBIES HAVE TAKEN OVER THE WORLD NOOOOOOOO!') game.workspace.freshmeat:play() end end Playing.Value = false KillPlayers() Wait(5) ResetPlayers() RemoveMessage() end)

while true do Wait(3) ResetPlayers() if (CountPlayers() >= 2) then RemoveMessage() PlayZombies() else DisplayMessage('') end end

1
You should format your code by clicking on the blue Lua icon and putting your code between the lines of "~"s. starlebVerse 685 — 7y
0
^^Do it nobody will read this like wtf goldstorm950 65 — 7y

1 answer

Log in to vote
3
Answered by 7 years ago

If you could, maybe add a code block. It will make your code fairly easier to read.

Its above the text block and to the right, it shows a Lua icon.

Also check this site out for some great tutorials on scripting in ROBLOX. I read most of it and it very greatly helped me out, some of them are outdated and may not work but most of them work.

http://wiki.roblox.com/index.php?title=AllTutorials ^ This is the ROBLOX wiki its a great site

Also http://wiki.roblox.com/index.php?title=Map_Chooser ^ This a tutorial from that site that I think may help you out with your question

Ad

Answer this question