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

Ray.new help, ignoring two different instance trees?

Asked by 8 years ago

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

Log in to vote
2
Answered by 8 years ago

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.

0
Thanks, that makes the script I'm coding much, much easier! xolbStudios 127 — 8y
0
No problem. Spongocardo 1991 — 8y
Ad

Answer this question