GetPartsObscuringTarget will return an array of BaseParts which had become semi-transparent.
But, looking at the Transparency property of the object in question, it doesn’t change when Invisicam is activated (it keeps always as 0).
And even though I change manually the object’s Transparency, it doesn’t affect the semi-transparency applied by Invisicam.
So, in this case, how do I detect that Invisicam has been triggered for an object?
Do I have to track all existing in-game objects inside a RenderStep?
Or is there any specific signal I can use for an object when it’s modified by Invisicam?
Hey. Good news: I found the solution. So Invisicam (just like all the other player control related stuffs) is being controlled by Roblox’s PlayerModule. That module gets loaded into every player’s PlayerScripts when the game starts. However, if there is already one there, it wont get loaded. So what you do is:
0. Set camera occlusion mode to “Invisicam” (you have already done this);
Click “Play Test” to test your game;
Now find your player in game.Players and find an object named PlayerScripts, then expand it and you are gonna see a whole bunch of stuff. Find a module named “PlayerModule”:
Now it’s very easy to detect any property change, like LocalTransparencyModifier.
Here’s my final solution, which will reduce the default (0.75) transparency to 0.5:
part:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
if part.LocalTransparencyModifier == 0.75 then
part.LocalTransparencyModifier = 0.5
end
end)
@Abcreator although it’s your idea, I’ll set this post as solution, since it has a code snippet to facilitate the consultation of future similar questions.
Thank you for the tip!
If I change the LocalTransparencyModifier inside its own GetPropertyChangedSignal("LocalTransparencyModifier"), it will create an infinite recursive loop…
I ran several tests and reached some important conclusions:
It’s no use changing the LocalTransparencyModifier value inside GetPropertyChangedSignal("LocalTransparencyModifier"). Roblox will not accept this change and will re-force the value 0.75 every time.
Here a project that’s showing this: invisicam.rbxl (26.4 KB)
When two or more parts are together, with no space between them, the value of LocalTransparencyModifier will fluctuate between 0.75 and 0.5 (as reported here):
Finally, the DevCameraOcclusionMode = Invisicam property acts for ALL objects, so I can’t specify a blacklist or whitelist for which objects I want to be affected by this property.
Taking all these restrictions into consideration, I conclude that it is easier and more flexible to create a Raycast script between the camera and the character, leaving only the parts that interest me semi-transparent.
I suggest using @debugger57 ‘s solution. You only need to change one variable, and if you are scared that you’ll miss an update, change the PlayerModule every once in a while. To me it seems like the easier solution.
Or, if you want to get really technical, you can copy the code inside the Invisicam module and make the appropriate edits (which could take a bit).
You’re right. It really was the simplest solution. I only realized this after getting hit a lot with all the bugs I reported above. I was already developing a whole ray method as I mentioned before, but your answer came just in time.
I was not aware that it was possible to hack this script.
Thank you for your insistence and your patience.
@debugger57 Thank you for your effort and your solution. There was only one problem when duplicating the original Invisicam script, showing the warning about Humanoid.Torso deprecated:
Well, there is only one remaining limitation, which I commented on before: Invisicam acts on ALL objects. How to create a whitelist or blacklist to choose only some objects to be affected by transparency?
Yeah, I also see that in the original InvisiCam script there are mentions of GetPartsObscuringTarget.
I just don’t know how to add items to the ignore list of this script.