Recently, I've been trying to make a camera that makes parts blocking the view of the character invisible, I have tried other ways but roblox physics was a pain in the ass. That was until I stumbled upon the :GetPartsObscuringTarget function. I have tried using it however it hasn't been working for me, eventhough I copied other people's example ( it worked for them not for me ) and tried to reverse engineer it to see how it worked because I was confused as hell. Either I don't think I've been using it properly or that it has changed.
If you don't know what the answer to that is, then can you give me another method that would help me achieve what I'm trying to do
You are able to use Raycasting to detect parts in the way between two points. In this case, the two points would be the character position and the camera position.
local function GetPartsBetweenPoints(Point0,Point1) local Direc = Point1 - Point0 --direction of character from camera local R = Ray.new(Point0, Direc) local PartsObscuring = {} repeat local Part = workspace:FindPartOnRayWithIgnoreList(R,PartsObscuring) table.insert(PartsObscuring,Part) --add obscuring part to table until not Part return PartsObscuring end local Obscuring = GetPartsBetweenPoints(Camera.CFrame.p, Character.HumanoidRootPart.Position)
Using this method, every time a new obscuring part is detected, it will be added to the PartsObscuring table. This table is also used as the IgnoreList for the Ray, meaning that it will not repeatedly detect the same parts. Basically, it will one-by-one detect parts between the character and the camera (on the ray), and add them to the table. You could then used this returned table to set the transparency of the parts in the way.
Hope this helps!