Where would it be if its not on the screen? Couldn’t you just check if its enabled true or false?
outside of the boundaries where you cant see it
Okay, i’m just really confused by the use case here. I assume that if its off the screen you (your script) has put it there so why would you need to detect it.
because moving a gui doesnt tell me if it’s out of boundaries or not ???
Right but you’re moving it, you know how big the screen is, why would you not know if its off the screen or not. I don’t get it.
Are you trying to move the gui with an endless loop and test its position somewhere and stop the loop?
I know what you’re asking for. Give me a few and I’ll write you something.
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:
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.
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.