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

How do I ignore multiple parts with Raycasting?

Okay so the basic code from the roblox wiki

			local ray = Ray.new(player.Lightning.WorldPosition.WorldPosition,player.HumanoidRootPart.CFrame.lookVector.unit*100)
local Part,Position = game.Workspace:FindPartOnRayWithIgnoreList(Ray,{player,game.Workspace.Noncollide})

I'm trying to make the raycast ignore a folder in workspace called "Noncollide" but the output says this "21:51:30.115 - Unable to cast Dictionary to Ray".

Does anyone know how to make the ray ignore multiple parts?

2 comments

0

you make ray but then you use Ray in the method?

0

Oh that was a mistake, i meant to put ray as in lowercase.

1 answer

✓ Accepted answer

Firstly, you defined the Ray as ray, and then used Ray in the FindPartOnRayWithIgnoreList function.

Secondly,you gotta define the ignore list using the GetChildren function on workspace.Noncollide.

local ray = Ray.new(player.Lightning.WorldPosition.WorldPosition,player.HumanoidRootPart.CFrame.lookVector.unit*100)

local ignore = workspace.Noncollide:GetChildren();
table.insert(ignore,player)

local Part,Position = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignore)

2 comments

0

Thank you so much!

0

This helped me too (even though this was posted 2 years ago). Upvoted!

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