Camera script help

I am trying to make it so a part disappears shortly after showing up in a players camera (like its transparency turns to 1).

specifically I want to have a player turn their camera, and then when they see certain parts, they dissapear.

I’m not familiar with cameras so it would be nice if somebody could help me achieve this disappearing part.

There’s no method to tell perfectly if an object is visible. There is a method to tell if the center of the part is onscreen, though.

If the Camera is in LockFirstPerson then you could insert a clickdetector inside the specific parts and then insert this script inside the clickdetector

local ClickDetector = script.Parent
local Time = 5 --time in seconds until the part is invisible
local DestroyedAfterTime = false --[[if set to true then the part will be 
destroyed after its invisible]]

    game:GetService("TweenService"):Create(ClickDetector.Parent,,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Transparency = 1}):Play()
    if DestroyedAfterTime == true then
--NOT TOO SURE IF IT WORKS! will be tested

Test results: WORKS!
not exactly what you wanted, but atleast its something? gonna make the camera thing if u want it

When you say “see”, do you mean hower thier mouse over the object, or just the object entering thier vission?,

If you mean when it enter vision? what’s the point?

field of vision, i’m making a horror game and i’m trying to make a subtle jumpscare by having there be some monster on the side of the screen. it will suddenly dissapear when it enters the side of their screen and in their field of view.

so the only way to tell if they’re looking at a part is to see if they’re hovering their mouse over it? what if i were to position the part right NEXT to their currentcamera and have a big hitbox around it. when you hit the invisible hitbox with your mouse it would set the transparency to 1. Do you think that would work?

Hey If you still haven’t found a solution, I have one:


local pos, onScreen = Camera:WorldToScreenPoint(object) -- Pos = Vector2 (dont Care), onScreen = Bool, true if on screen, false if not.

Remember that the onScreen bool will be true, even if there is a wall in between, If you care about walls, Then you should use raycast, to see if there is a wall inbetween or not,

ye that would. but you have to change the part from ClickDetector.Parent to YourPart :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.