So, I have a raycasting gun script, and it works great. No problems. However, when the bullet would hit an invisible part with CanCollide off, it doesn't go through it. This is a problem, as this means players can not shoot through doorways, and most importantly, the areas designated for fighting are defined using a giant invisible part around the area.

How would I make it ignore parts with Transparency of 1 and CanCollide as false?

--Obviously just a segment of the script, no reason to post the 250 line+ script.
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)

2 comments

0

Just if you find an invisible part that cannot collide then make a new ray that has that object in the ignore list, I think that should work.

0