Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Unable to cast dictionary to ray?

Asked by
Edenojack 171
7 years ago

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

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. Edenojack 171 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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
Ad

Answer this question