I am trying to make a team only door that only opens for a team, but this door only appears sometimes when the game wants it to, and this script activates when its spawned, the group the server script is in also is in a model, and the team name is in the said model, though, its not working, maybe cause the team door and is model? i dunno, but can you guys help me? i really need to get this update out :P

TeamColor="script.Parent.Name"
Time=3
AntiHack=2
ColorDoor=true
local found = script.Parent.awesomesauce.lazerprotection:FindFirstChild("DOOR")

Color=BrickColor.new(TeamColor)
on=false
s=script.Parent.awesomesauce.lazerprotection.DOOR
ss=script.Parent.awesomesauce.lazerprotection.DOOR:clone()
s.BrickColor=Color
function Check(hit) if on then return end
if hit==nil then return end
local player=game.Players:FindFirstChild(hit.Parent.Name)
if player==nil then return end
on=true
	if player.TeamColor==Color then
	s.Transparency=0.6
	s.CanCollide=false
	wait(Time)
	s.Transparency=ss.Transparency
	s.CanCollide=true
	else
	local h=player.Character:FindFirstChild("Humanoid")
	local t=player.Character:FindFirstChild("Torso")
	if t==nil or h==nil then s.CanCollide=true s.Transparency=ss.Transparency on=false return end
	if AntiHack==1 then
	h.Sit=true
	t.Velocity=t.CFrame:inverse().lookVector*80
	elseif AntiHack==2 then
	h.Health=0
	elseif AntiHack==0 then
	else hit.Parent=nil
	end
	end
on=false
end

if found then 
s.Touched:connect(Check)

wait (5)
print "TeamColor"