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

How do I set the value to GUI offset?

How do I set the value to GUI offset?

if script.Parent[""..number.Value].Position.X.Offset > 40 then
                script.Parent[""..number.Value].Position.X.Offset = 40 ---It wont let me do this
            end

I cant use UDIM2.new because that involves Y axis variables, but this system works on more then one frame with different Y positions. And I can't use + UDIM2.new because it's not always the exact same value over 40 every time.

1 answer

You can pass in the untouched portions of the current UDim2 when you create a new one to replace it.

Also, you don't have to concatenate to an empty string.

local pos = script.Parent[number.Value].Position --for less typing
script.Parent[number.Value].Position = UDim2.new(pos.X.Scale, 40, pos.Y.Scale, pos.Y.Offset)

2 comments

0

That actually sets x.scale to 0 therefore changing the Y Offset, scale and the X scale.

0

I don't understand what you mean. All four of the components of a UDim2 are independant of each other, and that code should only set X.Scale to 0 if it was 0 when the code was run.

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