Whats wrong with this?

My buddy sent me over a script for me to fix, and I can’t fix anything at all on it. Anybody know a fix for this?


local meta = FindMetaTable("Player")

if not ZombiePlayers then ZombiePlayers = {} end

function meta:IsZombie()
	if not IsValid(self) then return false end
	return self:Team() == TEAM_ZOMBIE
end

function meta:IsSurvivor()
	if not IsValid(self) then return false end
	return self:Team() == TEAM_SURVIVOR
end

local function RevertJob(p)
	if not IsValid(p) then return end
	local oJob = p.jobBefore or 1
	
	if p:IsZombie() then
		p:StripWeapons("hl2_combo_fists")
		p:SetRunSpeed(240)
		p:AddMoney(1000)
		Notify(p,0,4, "You have received $1000 dollars for participating. Go back to roleplaying.")
	elseif p:IsSurvivor() then
		p:AddMoney(1000)
		Notify(p,0,4, "You have received $1000 for surviving the zombie apocolypse.")
	end

	p:SetTeam(oJob)
	p:SetDarkRPVar("job", p.jobTitle)
	
	gamemode.Call("PlayerLoadout", p)
	gamemode.Call("PlayerSetModel", p)
	
	Notify(p,0,4, "You have been given your old job as a " .. team.GetName(oJob) .. ".")
	
	p.jobTitle = nil
	p.jobBefore = nil
end

local function InfectPlayer(p)
	if not IsValid(p) then return end
	if !p.jobBefore then p.jobBefore = p:Team() end
	if !p.jobTitle then p.jobTitle = p.DarkRPVars.job end
	p:SetTeam(TEAM_ZOMBIE)
	p:SetDarkRPVar("job", "Zombie")
	p:SetRunSpeed(350)
	p:StripWeapons()
	
	gamemode.Call("PlayerLoadout", p)
	gamemode.Call("PlayerSetModel", p)
	
	p:EmitSound("ambient/creatures/town_child_scream1.wav", 500, 100)
	Notify(p,0,4, "Infect your fellow citizens.")
end

local function SurvivorPlayer(p)
	if not IsValid(p) then return end
	if !p.jobBefore then p.jobBefore = p:Team() end
	if !p.jobTitle then p.jobTitle = p.DarkRPVars.job end
	p:SetTeam(TEAM_SURVIVOR)
	p:SetDarkRPVar("job", "Survivor")
	gamemode.Call("PlayerSetModel", p)
	Notify(p,0,4, "Try to not get infected by the other zombie players. Watch out, they're fast.")
end

local function PlayerShouldTakeDamage(vict, att)
	if att:IsPlayer() then
		if (att:IsSurvivor() && not vict:IsZombie()) then 
			return false
		elseif (att:IsZombie() && not vict:IsSurvivor()) then 
			return false 
		elseif ((!att:IsZombie() && !att:IsSurvivor()) && (vict:IsZombie() or vict:IsSurvivor())) then
			return false
		end
		return true
	end
end

local canUse = {}
canUse["prop_door_rotating"] = true
canUse["func_button"] = true

local function PlayerUse(p, e)
	if p:IsZombie() then
		if not canUse[e:GetClass()] then
			return false
		end
	end
end

local function PlayerSpawnProp(p, m)
	if p:IsZombie() then
		return false
	end
end

local function PlayerCanPickupWeapon(p, w)
	if p:IsZombie() then
		local w = w:GetClass()
		if w ~= "hl2_combo_fists" then 
			return false
		end
	end
end

local function PlayerDisconnected(p)
	ZombiePlayers[p:EntIndex()] = nil
end

local function PlayerDeath(v, i, a)
	if a:IsPlayer() then
		if v:IsZombie() && a:IsSurvivor() then
			Notify(a,0,4, "You have recieved $100 for killing a zombie player.")
			a:AddMoney(100)
		end
	end
end

local function PlayerSpawn(p)
	timer.Simple(1, function()
		if p:IsZombie() then
			p:SetRunSpeed(350)
		end
	end)
end

local function GetPlayerZombieCount()
	local count = 0;
	for k,v in pairs(ZombiePlayers) do
		if v:IsZombie() then
			count = count + 1
		end
	end
	return count;
end

local function EndZombieEvent()
	if table.Count(ZombiePlayers) == 0 then return end
	
	hook.Remove("PlayerShouldTakeDamage", "DRP_ZombieEvent")
	hook.Remove("PlayerUse", "DRP_ZombieEvent")
	hook.Remove("PlayerSpawn", "DRP_ZombieEvent")
	hook.Remove("PlayerSpawnProp", "DRP_ZombieEvent")
	hook.Remove("PlayerCanPickupWeapon", "DRP_ZombieEvent")
	hook.Remove("PlayerDeath", "DRP_ZombieEvent")
	hook.Remove("PlayerDisconnected", "DRP_ZombieEvent")
	
	for k,v in pairs(ZombiePlayers) do
		if v:IsZombie() or v:IsSurvivor() then
			RevertJob(v)
		end
	end
	NotifyAll(0,4, "The Zombie player event has ended.")
	timer.Simple(2, function()
		ZombiePlayers = {}
	end)
end

local function PlayerZombieEvent(answer, ent, initiator, target, TimeIsUp)
	if answer == 1 and !(ZombiePlayers[target:EntIndex()]) then
		ZombiePlayers[target:EntIndex()] = target
		Notify(target, 0,4, "You have entered the zombie event.")
	elseif answer and !(ZombiePlayers[target:EntIndex()]) then
		Notify(target, 0,4, "You did not enter the zombie event.")
	end
	
	if TimeIsUp then
		if table.Count(ZombiePlayers) < 2 then hook.Remove("PlayerDeath", "DRP_ZombieEvent") ZombiePlayers = {} return end
		hook.Add("PlayerShouldTakeDamage", "DRP_ZombieEvent", PlayerShouldTakeDamage)
		hook.Add("PlayerUse", "DRP_ZombieEvent", PlayerUse)
		hook.Add("PlayerSpawn", "DRP_ZombieEvent", PlayerSpawn)
		hook.Add("PlayerSpawnProp", "DRP_ZombieEvent", PlayerSpawnProp)
		hook.Add("PlayerCanPickupWeapon", "DRP_ZombieEvent", PlayerCanPickupWeapon)
		hook.Add("PlayerDeath", "DRP_ZombieEvent", PlayerDeath)
		
		local Rand = table.Random(ZombiePlayers)
		InfectPlayer(Rand)
		
		for k,v in pairs(ZombiePlayers) do
			if not v:IsZombie() then
				if math.random(10) == 1 then
					InfectPlayer(v)
				else
					SurvivorPlayer(v)
				end
			end
		end
		
		timer.Create("DRP_ZombieCheck", 1, 0, function()
			local perc = math.floor(table.Count(ZombiePlayers) * .8)
			if (GetPlayerZombieCount() >= perc) or (table.Count(ZombiePlayers) == GetPlayerZombieCount()) or (GetPlayerZombieCount() == 0) then
				
				EndZombieEvent()
				timer.Destroy("DRP_ZombieCheck")
			end
		end)
		
		timer.Simple(math.random(360, 720), function()
			EndZombieEvent()
			timer.Destroy("DRP_ZombieCheck")
		end)
	end
end

local function StartZombieEvent()
	for k,v in pairs(player.GetAll()) do
		if !RPArrestedPlayers[v:SteamID()] && v:Team() ~= TEAM_MAYOR then
			ques:Create("Participate in Zombie event?", "PlayerZombies"..tostring(k), v, 30, PlayerZombieEvent, p, v)
		end
	end
	
	hook.Add("PlayerDisconnected", "DRP_ZombieEvent", PlayerDisconnected)
	timer.Create("PlayerZombieEvent", 30, 1, function()
		PlayerZombieEvent(nil,nil,nil,nil,true)
	end)
end
EventSystem.Functions.AddEvent("PlayerZombieEvent", StartZombieEvent)

local function PlayerForceEndZombieEvent(p)
	if !p:IsSuperAdmin() then return end
	EndZombieEvent()
end
concommand.Add("EndPlayerZombieEvent", PlayerForceEndZombieEvent)

local SWEP = FindMetaTable("Weapon")

local openUp = {}
openUp["prop_door_rotating"] = true
openUp["func_door"] = true

function SWEP:DoorKnock(Entity)
	if self.Owner:IsZombie() then
		if Entity:IsPlayer() then
			if Entity:IsSurvivor() then
				self.Owner:SetSelfDarkRPVar("Energy", 100)
				InfectPlayer(Entity)
			end
		end
		
		if openUp[Entity:GetClass()] then
			if math.random(10) == 1 then
				Entity:Fire("unlock", "", .5)
				Entity:Fire("open", "", .6)
				Entity:Fire("setanimation", "open", .6)
				return
			end
		end
		
		if math.random(10) == 1 then
			self:Succeed()
		end
		
		return 
	end

	if self.Owner:Team() == TEAM_THUG then
		if Entity:GetClass() == "prop_door_rotating" && (Entity.DoorData && not Entity.DoorData.NonOwnable) then
			if self.Owner:CloseToCPs() && math.random(4) == 4 then
				self.Owner:Wanted("Breaking and Entering!")
				
				return
			end
			if math.random(100) == 1 then
				Entity:Fire("unlock", "", .5)
				Entity:Fire("open", "", .6)
				Entity:Fire("setanimation", "open", .6)
				Entity:EmitSound("physics/wood/wood_crate_break" ..math.random(5) .. ".wav")
				
				local pos = Entity:GetPos()
				local ang = Entity:GetAngles()
				local model = Entity:GetModel()
				local skin = Entity:GetSkin()
				
				self.Owner:AddKarma(-1)
				
				Entity:SetNotSolid(true)
				Entity:SetNoDraw(true)
				
				local function ResetDoor(door, fakedoor)
					door:SetNotSolid(false)
					door:SetNoDraw(false)
					fakedoor:Remove()
				end
				
				local norm = (pos - self.Owner:GetPos()):GetNormal()
				local push = 10000 * norm
				local ent = ents.Create("prop_physics")
				
				ent:SetPos(pos)
				ent:SetAngles(ang)
				ent:SetModel(model)

				if(skin) then
					ent:SetSkin(skin)
				end

				ent:Spawn()
				ent.ShareGravgun = true
				--
				timer.Simple(0.01, function()
					if IsValid(ent) then
						ent:SetVelocity(push)
						ent:GetPhysicsObject():ApplyForceCenter(push)
					end
				end)               
				timer.Simple(25,  function() ResetDoor(Entity, ent) end)
			end
		end
	end
end

Whats the error, no one is going to go through all that, what’s wrong with it so we know exactly where to look at that