Table index returns nil

After adding some roles this table now returns nil, any clue why? (and yes there are supposed to be Ls there)



alloweddoorgroup = {};
alloweddoorgroup[ TEAM_LPOLICE ] = true;
alloweddoorgroup[ TEAM_LCHIEF ] = true;
alloweddoorgroup[ TEAM_SWAT ] = true;
alloweddoorgroup[ TEAM_SCHIEF ] = true;
alloweddoorgroup[ TEAM_MAYOR ] = true;

function ENT:StartTouch( target )
if ( !IsValid( target) || !target:IsPlayer( ) ) then return; end
if !( alloweddoorgroup[ target:Team( ) ] ) then
	self:SetCollisionGroup( COLLISION_GROUP_NONE )
end
if ( alloweddoorgroup[ target:Team( ) ] ) then
	self:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
end
end



Maybe the TEAM_* variables aren’t defined before your script loads. If this is the issue the code below should sort it out by only adding the variables to the table after the gamemode loads.



alloweddoorgroup = {}

hook.Add("Initialize", "doorgroupthing", function()
    alloweddoorgroup[ TEAM_LPOLICE ] = true
    alloweddoorgroup[ TEAM_LCHIEF ] = true
    alloweddoorgroup[ TEAM_SWAT ] = true
    alloweddoorgroup[ TEAM_SCHIEF ] = true
    alloweddoorgroup[ TEAM_MAYOR ] = true
end)


Didn’t even think of that, that would explain why reloading it caused it to work. Thanks.