#how do i check if a gui goes off the screen

1 messages · Page 1 of 1 (latest)

frozen musk
#
    if currentgui.Position.X >= 0.98 then
        print("tofar")
    end```
prime nymph
#

Check if the GUI's AbsolutePosition is greater than the ScreenGui's AbsoluteSize property depending on the axis.

frozen musk
#

uh

prime nymph
#

(taking into account anchor pos too)

frozen musk
silver olive
frozen musk
#

bc after it goes pass 1 it is off the screen

prime nymph
prime nymph
# frozen musk wait why

scale is a percentage of the GUI's parent size.

So if the GUI isn't the width of the screen, it won't actually be going off screen

prime nymph
# frozen musk the parent is a screengui

AbsoluteSize and AbsolutePosition is in pixels.

.98 is 98% the size of the ScreenGui.

.98 isn't fully off screen anyway, why not 1?

I mean it'll probably work but I like the accuracy of the exact pixels

#

You'd still need to account for AnchorPos regardless of what you use.

frozen musk
prime nymph
frozen musk
#
        if currentgui.AbsolutePosition > script.Parent.AbsoluteSize then
            print("tofar")
        end
    end```
#

but it js gave me a error

#

06:27:37.997 Players.zombiesgamerash.PlayerGui.PiGUI.NumberTyper:160: attempt to compare Vector2 < Vector2 - Client - NumberTyper:160

prime nymph
prime nymph
frozen musk
#

alr

#

yay

#

it works now

frozen musk
#

sometimes the number gets to like 0.999 and is off the screen

prime nymph
# frozen musk but how would i do this

So if the anchor point is 0.5, 0, this means that the frame's X position will be offscreen, but half of the frame will still be on screen (as the origin is in the middle)

So the position has to now be greater than AbsoluteSize + (anchor * size)

prime nymph
frozen musk
#

anchor point of the gui or the screen gui??

prime nymph
frozen musk
#

um
06:40:54.399 Players.zombiesgamerash.PlayerGui.PiGUI.NumberTyper:160: invalid argument #1 (Vector2 expected, got number) - Client - NumberTyper:160

prime nymph
frozen musk
#

gtg

frozen musk
prime nymph
prime nymph
prime nymph
frozen musk
prime nymph
frozen musk
#

ohhhhhhhhhhhh

frozen musk
#

also am trying to create a new line

#

after it passes the screen

#
        if currentgui.AbsolutePosition.X > (script.Parent.AbsoluteSize.X - (currentgui.AbsoluteSize.X * currentgui.AnchorPoint.X)) * 0.92 then
            print("tofar")
            currentgui.Position = currentgui.Position + UDim2.new(0,0,0.040,0)
            currentgui.Position.X.Scale = 0
        end
    end```
prime nymph
frozen musk
prime nymph
frozen musk
prime nymph
prime nymph
#

@devout kindle Im so sorry for pinging you randomly, but this issue makes me feel like I'm taking crazy pills. Do you have any insight? Starting from #1356344009022242897 message

devout kindle
#

lemme see

#

what do u need insight on

#

X.Scale or Scale.X?

#

pretty sure it's X.Scale

prime nymph
devout kindle
#

currentgui.Position.X.Scale = 0

#

yeah ik why

#

u cant set Scale/Offset individually

#

u have to set the actual X value

#

that's why

#

sorry was trynna figure out wtf this guy is dming me

prime nymph
devout kindle
#

np

#

just chilling lmao

devout kindle
prime nymph
# devout kindle that's why

Why wouldn't it have a "read only" style error, rather than saying it's not a property? I was expecting possibly getting that kind of error.

Does it have to do with tables and various lua stuff?

devout kindle
#

idk it's just some roblox UI bs

prime nymph
#

Well at least I'm not crazy!

devout kindle
#

lmao

#

yeah nah u cant edit the UDim2 directly for whatever reason

#
if currentgui then
    if currentgui.AbsolutePosition.X > (script.Parent.AbsoluteSize.X - (currentgui.AbsoluteSize.X * currentgui.AnchorPoint.X)) * 0.92 then
        print("tofar")
        currentgui.Position = currentgui.Position + UDim2.new(0,0,0.040,0)
-       currentgui.Position.X.Scale = 0
+       currentgui.Position = UDim2.new(0, currentgui.Position.X.Offset, currentgui.Position.Y.Scale, currentgui.Position.Y.Offset);
        or
+       currentgui.Position -= UDim2.fromScale(currentgui.Position.X.Scale, 0);
    end
end
devout kindle
#

nvm

#

hol up

#

nah im trippin

#

this is why i dont stay up late

#

😭

prime nymph
#

I feel like they should just have "read-only" beside the member like all other languages have always done

devout kindle
#

mhm

#

bro what is this documentation

prime nymph
#

It's not even a descriptive error either, like it doesn't connect to the fact it's read only

devout kindle
#

"attempting to write to it causes an error"

#

💀

#

i mean i suppose "writing to it" would mean writing into the actual UDim2

#

not "assigning" it

#

still vague af

#

YOOO

#
#

kinda off topic but this is sick

#

i should probably go to bed now lmao

frozen musk
#

so how do i fix it