How do I check if a GUI is on screen?

Try this:

function IsGUIObjectOnScreen(Object)
	local CurrentCamera = workspace.CurrentCamera
	local ScreenSize = CurrentCamera.ViewportSize
	local Position, Size = Object.AbsolutePosition, Object.AbsoluteSize
	local Bounds = {
		X = {
			Min = -Size.X,
			Max = ScreenSize.X
		},
		Y = {
			Min = -Size.Y - 36,
			Max = ScreenSize.Y - 36
		}
	}
	
	if Position.X <= Bounds.X.Min or Position.X >= Bounds.X.Max then
		return false
	elseif Position.Y <= Bounds.Y.Min or Position.Y >= Bounds.Y.Max then
		return false
	end
	
	return true
end

An object is deemed “off screen” if there is no visible part of it. Do note: you may need to remove the - 36 in the Bounds if you have this option enabled in your ScreenGui:
image

nope, still not perfect

i’m asking a scripting question, not a personal one…

Okay, I’m not asking personal questions either. I’m trying to figure out what you’re trying to do which you want help with. You haven’t provided any script or even screenshot of how you are defining your frames. I think it will make a difference if you’re using scale vs offset. I’m not sure what the screenshots you keep showing are showing us. Is that transparent orange box your frame that you’re testing? What is the red part? Does that change colors depending on the test?

im using offset, i set the frame in the function to the frame you can see in the image,
and i already explained that ‘red part means function gave me false’

Can you show what the frame properties looks like for that screenshot example. The position and size numbers.

image
i meant im using scale, sorry for saying offset

Just check and see if it’s parent is PlayerGui.

Okay, so 1 is the right side, and 1 is the bottom. Depending if you have your anchor centered or top left, you need position of 1.516 to get off the right side, and 1.567 to get off the bottom of the screen, no? If its centered you’d have to do some dividing. Then to check top and left you’d need to check for negative positions. Maybe?

Move it off the screen and see what your numbers look like.

please read the post, i said ‘is on screen’, not ‘is existing’

Ha, we already went down that road, he wants it to be enabled, but off the screen. ?? Don’t ask why, that’s a personal question.

oh, does the function only do one point, if so then that doesnt work for me
a solution i thought of is maybe checking if all of the corners are on the screen, but i dont know how to do that

You just need to make sure it’s visible and it’s parent is playergui.

Excuse me, I did read the post. I guess I just don’t understand why you need this.

What function, I didn’t give you any function. I’m just trying to give you ideas of how to can check if a gui that you’re putting on the screen, is off the screen or not. None of this makes sense to me, haha.

okay, then i think you dont understand how guis work.
guis dont go invisible when they are out of boundaries

i think the function only does one point (like currentcamera:WorldToViewportPoint)

Okay, but I don’t know what function you’re talking about. A function that someone wrote for you here? You need to make your own function if you want to do this.

I think he is just confused as to why you’d want to send a gui out of bounds, and not know that you did it and need to test for it. (like I was)

You should be able to write this function like, if position > 1+ size then print(“gui is not visible”)

pseudo code

i think im going to try to get the corners and see if they are out of the screen or not