So, I have this invisible block (part) - (actually multiple of them) but I want to make it where you can still shoot through it but you can’t go pass it. I have this shooting range for a turf and I just want the players where they can like shoot through the invisible part but can’t go through it in any way, how do I do that?
Don’t worry, I know how to make invisible parts, I just need some help on coding/scripting it like I mentioned above.
Cause like if people shoot the invisible part, it will lead like those little bullet dots on the invisible part and I don’t want it to look bad, instead I want it to be on the targets. Idk how to explain it, really.
I assume your shooting script uses raycasting. What you can do is, when it hits a target instance, check if the instance is transparent. If it is, then fire another ray from the position of the hit position of the previous raycast with a distance of (total distance - previous ray distance). You need to do this recursively until your max bullet distance is reached.
If you are using raycasting like Imagine_Developing said, you can exempt any BasePart from hit detection by setting its BasePart.CanQuery property to false.
local part = workspace.Part -- Your path to the part
-- Shoot event gets fired, and place this snippet inside the shoot event on the server side
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Include
rayParams.FilterDescendantsInstances = {part}
-- IMPORTANT NOTE. READ: I am using "Include" which means it will only include the parts given in FilterDescendantsInstances. Make sure you add every folder that you want the raycast to go through.
-- Now, raycast and at the end, add the rayParams.
-- Example: workspace:Raycast(origin, direction, rayParams)