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

Ray.new help, ignoring two different instance trees?

I have no clue as to how to do this... I tried this (sample code)

local ray = Ray.new(pos1,(pos2-pos1).unit*750)
local ignores = {game.Player.Player1.Character,game.Workspace.Inbetween}
local hit,pos = game.Workspace:FindPartOnRay(ray,ignores)

but I didn't seem to work. Any tips or code you guys can offer me?

1 answer

✓ Accepted answer

To ignore multiple objects when finding a part on a ray, you need to use FindPartOnRayWithIgnoreList. FindPartOnRay only accepts one instance, while FindPartOnRayWithIgnoreList accepts an array of instances to ignore when finding a part on the line of a ray.

local ray = Ray.new(pos1,(pos2-pos1).unit*750)
local ignores = {game.Player.Player1.Character,game.Workspace.Inbetween}
local hit,pos = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignores) --Finds a part on the ray with the current ray and ignores the instances in the ignores array.

I hope my answer helped you. If it did, be sure to accept it.

2 comments

0

Thanks, that makes the script I'm coding much, much easier!

0

No problem.

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