Wont return table no errors


 

alloweddoorgroup = {
	"TEAM_HOBO",
	"TEAM_POLICE"
}


 function ENT:Touch( hitEnt)
local t = hitEnt:Team() -- Final solution
local allowed = table.concat(alloweddoorgroup)
 	if hitEnt:IsPlayer() and ((t == (TEAM_POLICE)) or (t == (allowed))) then
		print("i like fick")
		self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
	end

	
end


It doesnt print when TEAM_HOBO and I dont know why. No errors are returned.

So the issue is, t == allowed won’t ever work…

When you do table.concat, it doesn’t put spaces in etc. So basically it becomes “TEAM_HOBOTEAM_POLICE”.

Also, those are ENUMs, meaning they aren’t a string.

used something like:

[lua]alloweddoorgroup = { };
alloweddoorgroup[ TEAM_HOBO ] = true;
alloweddoorgroup[ TEAM_POLICE ] = true;

function ENT:Touch( target )
if ( !IsValid( target) || !target:IsPlayer( ) ) then return; end
if ( alloweddoorgroup[ target:Team( ) ] ) then
print( “IT WORKED!!!” );
self:SetCollisionGroup( COLLISION_GROUP_DEBRIS );
end
end[/lua]

Read this and see why direct access is so important: https://dl.dropboxusercontent.com/u/26074909/tutoring/benchmarking_tips/benchmarking_hud_stuff.lua