Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Nootian 184
4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
Raccoonyz 1092 Donator Moderation Voter
4 years ago

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) 
Ad
Log in to vote
1
Answered by
Maxis_s 97
4 years ago
Edited 4 years ago

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

Answer this question