Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How do I prevent a gui from going past the X/Y borders of it's parent container?

Asked by
Fifkee 2017 Administrator Moderation Voter Community Moderator
1 year ago
Edited 1 year ago

I'm planning to make a GUI-based game, but I have little experience with arithmetics when it comes to the Vector and UDim sets.


What I want to do:

I want to be able to have a player-controllable frame (already handled) that cannot escape the borders of it's parent container, specifically, another frame. The issue is that I don't know how to go about this. I attempted to use the AbsolutePosition values of the parent container, and it worked on the positive scale, but not the negative. Yes, once the frame reaches the left side of the parent container's border, the AbsolutePosition.X value equates to the parent container's. But, if it were to head towards the right or bottom of the container, that is when the issue occurs. Setting the value to negative doesn't help, as it doesn't reach the right side of the border. Does anybody know how to go about doing this? If so, please share your information to the public!

Too long; didn't read: Read the title.

(if the question is a bit too vague, i will gladly give more information. don't be afraid to ask!)

also yeah i searched this up and haven't found anything if this is a dupe lmk ty

0
Use math.clamp() User#24403 42 — 1y
0
how would I use that to prevent leaving a boundry? i'm confused, the answer you gave me is vague Fifkee 2017 — 1y

Answer this question