For this solution to work, you’ll need to fetch the PlayerModule and parent it to StarterPlayerScripts located in StarterPlayer.
So I myself experienced a similar problem, just with spheres. I wanted to be able to see through them, even though they were visible and had CanCollide set to true, a friend of mine taught me a way to customize the CameraModule, so here we go.
You need to first fetch the PlayerModule obviously, and parent it to StarterPlayerScripts. To do this, go into play solo in Roblox Studio with the explorer open, find StarterPlayerScripts and there you should have PlayerModule. Now copy PlayerModule, and then stop the play solo. Now paste the PlayerModule into StarterPlayerScripts, and now we can actually begin with the actual solution.
Find a module called “Popper”, which is in ZoomController, in the CameraModule. Open it up, and you’ll see the description of it is “Prevents your camera from clipping through walls.”. Now do
Ctrl + F and find the function
canOcclude. Now you’ll find these comments,
-- Occluders must be:
-- 1. Opaque
-- 2. Interactable
-- 3. Not in the same assembly as the subject
you can ignore these comments. I assume it’s when someone wants to edit them at Roblox.
Let’s focus on what it returns. It should return a bool. If the bool returns false, it should clip through the object of the argument. If you return true, it doesn’t clip through. Now I’m gonna use
.Name for this,
however what I’d recommend would be that you use CollectionService to tag certain objects as CanOcclude, so that you can’t clip through those objects. This script will check for the
.Name from the passed object to the function.
return part.Name == "ObjectNameHere" or
getTotalTransparency(part) < 0.25 and
subjectRoot ~= (part:GetRootPart() or part) and
What this does is to check the
part.Name, and if the part’s name is “ObjectNameHere”, it will return true, and it won’t clip through the wall, otherwise it lets Roblox do their normal checks.