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

How to make a ray ignore a table of objects?

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.

1 comment

0

Do not only post code, or only post an explanation. Both are required to make a good question.

1 answer

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

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