I am trying to have a turret shoot lasers at nearby players, but I am stuck: when I try to use “FindPartOnRayWithIgnoreList”, it errors that “Unable to cast value to Object”. I assumed that I’m passing the ignorelist incorrectly, but I seem to not understand where.
local map = workspace.Map:FindFirstChild("Map")
local ignorelist = {}
if map then --
local mapparts = map:GetDescendants()
for _,v in pairs(mapparts) do
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("UnionOperation") then
if v.CanCollide == false then
table.insert(ignorelist,v)
end
end
end
end
--add ignoreparts
for i,v in pairs(ignoreparts) do
table.insert(ignorelist,v)
end
local ray = Ray.new(FiringCap.Position,FiringCap.CFrame.LookVector * 100)
local part, position = workspace:FindPartOnRayWithIgnoreList(ray, ignorelist) --errors
It seemed that I couldn’t find relatable problems with the list.