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

How do I ignore multiple parts with Raycasting?

Asked by 7 years ago

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?

0
you make `ray` but then you use `Ray` in the method? creeperhunter76 554 — 7y
0
Oh that was a mistake, i meant to put ray as in lowercase. Witchest 48 — 7y

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

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)
0
Thank you so much! Witchest 48 — 7y
0
This helped me too (even though this was posted 2 years ago). Upvoted! FlabbyBoiii 81 — 4y
Ad

Answer this question