generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Is it possible to change a GUI's position from offset to Scale?

Previous Thread :: Next Thread 
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
26 May 2010 06:07 PM
Like, if i have a GUI with a position of UDim2.new(0,250,0,250), how would i change it to UDim2.new(Numberhere,0,numberhere,0)?
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
26 May 2010 06:15 PM
Its possible, lucky you, I made it yesterday, here, it'll check the script thats farther in the screen and then convert everything:

local right = 0
t = {}
local starter = nil
function get(where)
for i, v in pairs(where:children()) do
if v.className:find("Gui") and v.className~="StarterGui" and v.className ~= "ScreenGui" then
table.insert(t, v)
elseif v.className == "ScreenGui" then
starter = v
end
get(v)
end
end
get(game.StarterGui)
local most = nil
for i, v in pairs(t) do
if v.Size.X.Offset+v.Position.X.Offset > right then
right = v.Size.X.Offset+v.Position.X.Offset
most = v:clone()
end
end
for i, v in pairs(t) do
for _, b in pairs({"Size", "Position"}) do
v[b] = UDim2.new(v[b].X.Offset/right, 0, (v[b].Y.Offset/v[b].Y.Offset)*v[b].Y.Offset/most*starter.AbsoluteSize.x/starter.AbsoluteSize.y, 0)
end
end
Report Abuse
Raven5888 is not online. Raven5888
Joined: 12 Feb 2009
Total Posts: 269
26 May 2010 06:16 PM
200/PixelsOfYourScreen
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
26 May 2010 06:19 PM
Raven, thats not right, in-game screen doesn't have the exact same size in pixels as your screen's resolution, also, it was 250, not 200...
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
26 May 2010 06:50 PM
Whoa, where'd the variables v and b come from?
Report Abuse
scipiothegreat is not online. scipiothegreat
Joined: 25 Apr 2008
Total Posts: 4114
26 May 2010 07:20 PM
I would assume

x.Offset/gui.AbsoluteSize.x

so if the offset was 200 and the screen was 800, you would get 0.25, which work.
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
26 May 2010 07:22 PM
Scipio knows about math. xP
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image