#how do i check if a gui goes off the screen
1 messages · Page 1 of 1 (latest)
Check if the GUI's AbsolutePosition is greater than the ScreenGui's AbsoluteSize property depending on the axis.
uh
(taking into account anchor pos too)
what about js using this
should add the absolutesize * anchor point of the axis because if it is too big and the anchor point is in the middle is not working
bc after it goes pass 1 it is off the screen
Yes good catch thank you
Sure but .98 may be different amounts on different screens
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
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.
if a number is at 0.999 and its under 1 so i can type again but then it passes 1 and goes off the screen
Weren't you asking how to detect if it was off screen?
okay so i tired this
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
Unfortunately you can't compare Vector2s (as the error says), so instead compare their components.
like the x axis?
Yes, X & Y are components of a Vector2
but how would i do this
sometimes the number gets to like 0.999 and is off the screen
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)
Does that actually matter? How noticeable even is that? We're using pixels in these calcs so don't worry about the percentage for that
anchor point of the gui or the screen gui??
You'd get the Absolute size of the thing it's exiting, but subtract the size of the thing exiting * anchor
soo like this?
if currentgui.AbsolutePosition.X > (script.Parent.AbsoluteSize.X - (currentgui.AbsoluteSize * currentgui.AnchorPoint)) then
print("tofar")
end
end```
um
06:40:54.399 Players.zombiesgamerash.PlayerGui.PiGUI.NumberTyper:160: invalid argument #1 (Vector2 expected, got number) - Client - NumberTyper:160
multiplying two Vector2s equal a Vector2. You can't subtract a number and a Vector2 (I don't think) so you need to be doing the .X of both Vector2s you're using
gtg
how do i fix this
17:46:17.707 X is not a valid member of UDim2 - Client - NumberTyper:163
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 = 0
end
end```
A GUI's position is not a Vector2, its a UDim2. So you can't do .X You'd have to get the X component of the .Scale or .Offset of the Position
so how would i do that
Instead of just Position.X you gotta do Position.Offset.X or Position.Scale.X depending on what you want
that doesnt work
what do you mean "that doesn't work"?
there is no option for that
Oh sorry I had it mixed up.
X.Offset or X.Scale
ohhhhhhhhhhhh
19:18:37.001 Scale is not a valid member of UDim - Client - NumberTyper:163 it js gives a simliar error
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```
Not sure how this is possible.
You don't set gui position like this anyway, you have to set the position to a new UDim2
i cant set it to a new udim2 tho because of this line
currentgui.Position = currentgui.Position + UDim2.new(0,0,0.040,0)
it always has to go down from the other line
Can you show me the line this points to? this doesn't make sense considering the docs say otherwise https://create.roblox.com/docs/reference/engine/datatypes/UDim
currentgui.Position.X.Scale = 0
Can you print out currentgui.Position.X?
@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
lemme see
what do u need insight on
X.Scale or Scale.X?
pretty sure it's X.Scale
but it's saying that Scale is not a valid member of UDim
X is a UDim from UDim2, so why wouldn't UDim have a Scale property?
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
No worries, you're very kind to answer my random ping
as in u have to set .Position
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?
idk it's just some roblox UI bs
Well at least I'm not crazy!
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
one of those cases where roblox just decided "oh nope, no documenting for this" 🤷
nvm
hol up
nah im trippin
this is why i dont stay up late
😭
I feel like they should just have "read-only" beside the member like all other languages have always done
It's not even a descriptive error either, like it doesn't connect to the fact it's read only
"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
Hi Creators, Last year at RDC we previewed Custom Matchmaking, a powerful way to control how players are matched in your games, improving both competitive and cooperative play. Since then, we’ve been hard at work finding a solution that works with our existing matchmaking algorithm while introducing custom variables that let you fine-tune it ...
kinda off topic but this is sick
i should probably go to bed now lmao
Awesome!!!! love new features
so how do i fix it