I’ve seen games like Banana Eats use this in which the player hiding in lockers or hidden parts would be able to peak out the walls of the locker because they would turn transparent since the player is close. I’m not sure how I could do this, I have looked for previous posts, but none have really helped my situation.
I have models in my game like trash cans, lockers, boxes, etc. and I would like to make them transparent when a player is hiding inside so the player can look outside of it while hiding.
You have to fork the PlayerScripts, and edit the ModuleScript named “Popper” (not “PopperCam”). Find this function and change the rules to suit your game:
local function canOcclude(part)
-- Occluders must be:
-- 1. Opaque
-- 2. Interactable
-- 3. Not in the same assembly as the subject
getTotalTransparency(part) < 0.25 and
subjectRoot ~= (part:GetRootPart() or part) and
Actually, what you describe is a little different that what you’ll get modifying Popper. If you modify the Popper function, it will let you hide in a locker, but have your camera outside the locker, still able to look around (like in Murder Mystery 2).
It sounds like what you might want instead is to use Part.LocalTransparencyModifier from a LocalScript to temporarily make things like locker doors or sides transparent, only on your client, when the player’s camera is inside the locker. An easy way to do this is to make a non-collidable, invisible part that fills the interior volume of the locker. Then, on RenderStepped, check if the Camera.Position is inside the bounds of this Part. If it is, make the walls and door of the locker mostly transparent.