LazokkYT
(where)
July 11, 2021, 12:52am
#1
I am trying to make it so that if the player’s mouse is hovering over a gui object, it has a gui that moves with the mouse. It’s working, but the problem is is that sometimes it can move outside the player’s screen. Is there any way I can detect when it’s outside of the player’s screen? For example, Adopt Me has something like this: yes - Album on Imgur
Anyone know how to do this (detecting it)?
1 Like
ThisAmAlt
(ThisAmAlt)
July 11, 2021, 12:58am
#2
hmmm…
i don’t know exactly but,
maybe you could make some sort of like… region2 somehow?
then detect if the guis position is in the region2
I don’t know how you would do this, but that’s all I could think of…
Hope this helps!
detect that the scale reaches 1 then change its position
1 Like
Every GuiObject has an AbsoluteSize
property which tells you exactly how big the object is.
There are four conditions to determine if an object is out of bounds of the player’s screen.
GuiObject.AbsoluteSize.X + MousePosition.X < 0
GuiObject.AbsoluteSize.X + MousePosition.X > ScreenGui.AbsoluteSize.X
GuiObject.AbsoluteSize.Y + MousePosition.Y < 0
GuiObject.AbsoluteSize.Y + MousePosition.Y > ScreenGui.AbsoluteSize.Y
2 Likes
You can use the GuiObject’s Position
and Size
to determine if it’s off the screen.
GuiObject.Position.X.Scale + GuiObject.Size.X.Scale
GuiObject.Position.Y.Scale + GuiObject.Size.Y.Scale
if either of these are greater than 1, you will know the GuiObject is beyond the right or bottom of the screen.