Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I take the individual offset of a Screen Gui?

If I do this:


function GUIChanger(GUI)
	GUIx = GUI.Size.X
	GUIy = GUI.Size.Y

	--This wont work:
	GUIx = GUIx+1
end
--Giving the GUI:
GUIChanger(StarterGui.GUI.Button)

This wont work because the GUIx value ends up being: {Value,Value}, Both offset and scale, How would I make these separate?

2 answers

✓ Accepted answer

Size on ROBLOX API reference

You'd have to use UDim2.new(). For example,

local x = GUI.Size.X.Scale + 1
local y = GUI.Size.Y.Scale
local xoffset = GUI.Size.X.Offset
local yoffset = GUI.Size.Y.Offset
UDim2.new(x, xoffset, y, yoffset) 

You have to use UDim2(XScale,XOffset,YScale,YOffset) rather than X and Y.

Therefore, this is a working script:

local GUI = game.StarterGui.ScreenGui.Frame --change this to whatever gui you want

function GUIChanger()
    local newSize = UDim2.new(0,0,0,0) --change this to whatever size you want

    GUI.Size = newSize
end

GUIChanger(StarterGui.GUI.Button)

Hope this helps!

-Maxis_s

This discussion is preserved as it was. New answers, comments, and votes are closed.