Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Unable to cast dictionary to ray?

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! :)

1 comment

0

lets hold the phone, not only did I just copy + past the wrong code, but I placed a number after the incorrect code... Fix this now.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.