So I'm using this function to check if an enemy can see the player:
local Ray = Ray.new(NPCmodel:findFirstChild("Head").Position,(Player.Character.Head.Position-NPCmodel:findFirstChild("Head").Position).unit*250) local ign = {EnemyFolder} table.insert(ign,DeadFolder) local hit,pos,norm = game.Workspace:FindPartOnRayWithIgnoreList(Ray,ign)
NPCmodel is the parent of the module this code is in, EnemyFolder is a folder, holding all the enemy models inside, DeadFolder is another folder, holding all things to be ignored by rays.
it gives me this: Unable to cast Dictionary to Ray. Which is fair enough, however the function to get to this function uses THE EXACT SAME CODE. I'm at a loss to understand what I'm doing wrong :( If anyone knows whats up, I'd really appreciate some help! :)
I suggest inserting each child from the DeadFolder and EnemyFolder into ign.
for i,v in pairs(EnemyFolder:GetChildren())do table.insert(ign,v) end for i,v in pairs(DeadFolder:GetChildren())do table.insert(ign,v) end