How do I finish a script's function?
I'm just starting scripting, but still beginning. I'm working on this script (Pasted Below) but some functions within it aren't working, I could really use help fixing it. If you can, edit the parts that are needing to be fixing, because I'm not sure whats going on with it. Thanks.
THE SCRIPT:
001 | system = script.Parent |
002 | is_playing = system.Playing |
005 | weapons = game.Workspace.Weapons |
007 | hum_team = game.Teams [ "Humans" ] |
008 | zom_team = game.Teams [ "Zombies" ] |
018 | function displayHint(text) |
020 | hint = Instance.new( "Hint" ) |
022 | hint.Parent = game.Workspace |
029 | if (hint~ = nil ) then hint:remove() hint = nil end |
032 | function displayMsg(text) |
034 | msg = Instance.new( "Message" ) |
036 | msg.Parent = game.Workspace |
043 | if (msg~ = nil ) then msg:remove() msg = nil end |
046 | function giveWeapons() |
047 | local player = game.Players:GetChildren() |
049 | for p = 1 , #player do |
050 | if (player [ p ] .TeamColor = = hum_team.TeamColor) then |
051 | weapons.Pistol.Value:Clone().Parent = player [ p ] .Backpack |
057 | function killPlayers() |
058 | local player = game.Players:GetChildren() |
060 | for p = 1 , #player do |
061 | if (player [ p ] .Character~ = nil ) then |
062 | local h = player [ p ] .Character:FindFirstChild( "Humanoid" ) |
064 | player [ p ] .Character.Humanoid.Health = 0 |
066 | if (player [ p ] :FindFirstChild( "Dead" )~ = nil ) then |
067 | player [ p ] .Dead.Value = false |
068 | player [ p ] .Class.Value = "Zombie" |
069 | player [ p ] .TeamColor = hum_team.TeamColor |
077 | function resetPlayers() |
078 | local player = game.Players:GetChildren() |
080 | for p = 1 , #player do |
081 | if (player [ p ] :FindFirstChild( "Dead" )~ = nil ) then |
082 | player [ p ] .Dead.Value = false |
083 | player [ p ] .Class.Value = "Zombie" |
084 | player [ p ] .TeamColor = hum_team.TeamColor |
090 | function countPlayers() |
092 | local player = game.Players:GetChildren() |
094 | for p = 1 , #player do |
095 | if (player [ p ] .Character~ = nil ) then |
103 | function countPlayersInTeam(team) |
105 | local player = game.Players:GetChildren() |
107 | for p = 1 , #player do |
108 | if (player [ p ] .TeamColor = = team.TeamColor) then |
109 | team_count = team_count + 1 |
116 | function assignZombies(amount) |
117 | local valid_players = { } |
118 | local player = game.Players:GetChildren() |
120 | for p = 1 , #player do |
121 | if (player [ p ] .TeamColor = = hum_team.TeamColor) and |
122 | (player [ p ] .Character~ = nil ) then |
123 | table.insert(valid_players,player [ p ] ) |
128 | if (#valid_players>amount) then |
130 | local rand = math.random( 1 ,#valid_players) |
132 | local chosen = valid_players [ rand ] |
133 | chosen.TeamColor = zom_team.TeamColor |
134 | chosen.Character.Humanoid.Health = 0 |
136 | table.remove(valid_players,rand) |
147 | if (minutes< 0 ) then playing = false return true end |
153 | function playZombies() |
154 | if (countPlayers()< = 3 ) then |
156 | elseif (countPlayers()< = 6 ) then |
162 | is_playing.Value = true |
163 | displayMsg( "Human team, survive the zombie team for 15 minutes to win the game, or else zombies win!" ) |
173 | while (playing = = true ) and (countDown() = = false ) do |
174 | local humans = countPlayersInTeam(hum_team) |
175 | local zombies = countPlayersInTeam(zom_team) |
177 | if (minutes = = 9 ) and (seconds = = 59 ) then |
179 | displayMsg( "Fast Zombie unlocked! Zombie team, chat '/fastzombie' to play as one next time you respawn!" ) |
181 | elseif (minutes = = 4 ) and (seconds = = 59 ) then |
183 | displayMsg( "Kamikaze Zombie unlocked! Zombie team, chat '/kamizombie' to play as one next time you respawn!" ) |
188 | displayHint( "Humans left: " ..humans.. " | Time left: " ..minutes.. ":0" ..seconds.. " | Zombies: " ..zombies) |
190 | displayHint( "Humans left: " ..humans.. " | Time left: " ..minutes.. ":" ..seconds.. " | Zombies: " ..zombies) |
194 | if (countPlayers()> = 2 ) then |
195 | if (countPlayers()< = 3 ) then |
197 | elseif (countPlayers()< = 6 ) then |
208 | if (humans = = 0 ) then break end |
215 | if (interrupted = = true ) then |
216 | displayMsg( "There are not enough players to continue the game..." ) |
218 | if (playing = = false ) then |
219 | displayMsg( "Humans have won the match by successfully surviving for 15 minutes!" ) |
221 | displayMsg( "Zombies have won by successfully infecting all humans within 15 minutes!" ) |
225 | is_playing.Value = false |
237 | if (countPlayers()> = 2 ) then |
241 | displayMsg( "Waiting for two or more players..." ) |