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

How to make a ray ignore a table of objects?

Asked by 6 years ago

Basically I want a ray to ignore every HumanoidRootPart it hits. I made a table containing the parts but it errors: Unable to cast value to Object I'm using FindPartOnRayWithIgnoreList by the way as there are other models I want to ignore. It works if I list it like tihs: ignoreTable[1], ignoreTable[2] etc.. as many times as many max players I have but there has to be a better way.

0
Do not only post code, or only post an explanation. Both are required to make a good question. hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago

Here, let's start from scratch to make the table. First I'm going to create a for loop and see if their character and humanoidrootpart is not nil, then add it to the ignorelist table

local ignorelist = {}
for _,v in pairs(game.Players:GetPlayers()) do
    if v.Character and v.Character:FindFirstChild("HumanoidRootPart")~=nil then
        table.insert(ignorelist,v.Character.HumanoidRootPart)
    end
end

Now I have a table to give FindPartOnRayWithIgnoreList that includes every player's humanoidrootpart

Ad

Answer this question