|
| 04 Oct 2013 08:51 PM |
I basically have a ScreenGui with frames in them. Each frame is a page that you can view. In all of the frames I have the following script to make the Frame's size equal to the Roblox browser's size.
while wait(.1) do script.Parent.Size = UDim2.new(1, 0, 1, 0) end
Now I need a script that will change the position of everything in the frames to be proportional to the prior size. I threw together a little script to do that. I'm not sure why it doesn't work.
originalsize = UDim2.new(0, 806, 0, 584) script.Parent.Changed:connect(function(property) if property == "Size" then c = script.Parent:GetChildren() newsize = script.Parent.Size for i = #c, 1, -1 do c[i].Position = c[i].Position + (newsize - originalsize) end end end)
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2013 08:53 PM |
What I mean by "to be proportional to the prior size" is if you had a TextLabel that was in the center of the screen with the original size, it will adjust to be in the center of the screen with the new size.
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 04 Oct 2013 10:15 PM |
| Center: UDim2.new(0.5, -(gui.Size.X.Absolute), 0.5, -(gui.size.Y.Absolute)) |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2013 10:27 PM |
I'm not asking for the code to center everything since not everything is centered in the Gui. Some things are to the side. I need a code that will change the position of everything to make it proportional to the new size. For example: if the size increases by UDim2.new(0, 5, 0, 2) then the position of everything will increase by UDim2.new(0, 5, 0, 2).
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 04 Oct 2013 10:37 PM |
| Use the relative positioning to position everything about how you want it. |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2013 10:38 PM |
I'm facedesking right now. I provided code that I want debugged. I'll re-post it.
originalsize = UDim2.new(0, 806, 0, 584) script.Parent.Changed:connect(function(property) if property == "Size" then c = script.Parent:GetChildren() newsize = script.Parent.Size for i = #c, 1, -1 do c[i].Position = c[i].Position + (newsize - originalsize) end end end)
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|
|
| 05 Oct 2013 12:39 AM |
Morash was right. He's saying you can set all the Guis up to work regardless of screen size. Set everything up to offset based on a certain percentage of the screen (normally .5). So if you want something centered, position would be .5 - size.x / 2.
This will automatically update without having to worry about scripts. |
|
|
| Report Abuse |
|
|