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

Manually adding parts to an ignore list for a ray?

Asked by
gitrog 326 Moderation Voter
6 years ago

So, I have a raycasting gun, and I want it to go through parts with Transparency as 1 and with CanCollide as false. Can't figure out how do to this with FindPartOnRayWithIgnoreList. Can I get some help?

--ray creation
local NewPos =  mouse + Vector3.new(math.random(-spread,spread), math.random(-spread,spread), math.random(-spread, spread))
local ray = Ray.new(tool.firePart.CFrame.p, (NewPos - tool.firePart.CFrame.p).unit*300)
local part, position = game.Workspace:FindPartOnRay(ray, player.Character, false, true)
0
I don't want to add every single part that has a Transparency of 1 and CanCollide as false, it's a rather large map. gitrog 326 — 6y
0
Well if you dont want to do it that way because of the number of parts in the workspace, you could creat a region centered at the player and make it as big as your gun's range then u can make a tabel by looking through all of the parts found in the region that are of transparency = 1 Worthy0ne 68 — 6y
0
Not sure if this method is more 'efficient' but its diffrent :3 Worthy0ne 68 — 6y
0
That sounds like it's gonna slow down the game a lot. Is there a way to just check when it hits? gitrog 326 — 6y

Answer this question