In my script I have a part that gets mouse position for a BodyVelocity. When I aim a bullet at a part that has anchored set to true and cancollide set to true, it works fine, same if I aim it at a player. But if I aim it at a part that has anchored set to true and cancollide set to false, then my mouse position screws up and ends up sending my bullet towards a point which is not where my mouse was pointing at. Anyone know how to fix this? I would give code but my code has no errors I can see or fix so I'm really confused as to why it is doing this. All I want the bullet to do is act as if that cancollide false part isn't there and just go through it to wherever I'm pointing.
There's TargetFilter, which will allow you to ignore an instance and all it's descendants. This will only work when you use mouse.Target to get a target though.
game.Players.LocalPlayer:GetMouse().TargetFilter = Instance
If you simply put everything you want it to ignore in the same model and then set TargetFilter to that model, it will ignore everything inside the model as if it wasnt there (just for the read-out of Mouse.Target)
Unfortunately CanCollide
does not mean the mouse will ignore it, the property is designed to make building easier in some situations. For a helpful solution, assuming there is one, I would need more information on the parts you are trying to ignore, and their vitality to the game, etc.
For now, I can offer two solutions.
Firstly, as Skepticalitys said, you can simply remove the CanCollide
parts from your game, removing the option to shoot through parts altogether.
Secondly, you could put a local script inside the gun that temporarily removes the parts from the workspace while aiming at them. With FE enabled this would only remove the parts for the specific client, and everyone else could still see the parts normally. How you were to go about applying this method is up to you, there are multiple options.