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

How do I set the value to GUI offset?

Asked by 10 years ago

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

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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)
0
That actually sets x.scale to 0 therefore changing the Y Offset, scale and the X scale. Orlando777 315 — 10y
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. adark 5487 — 10y
Ad

Answer this question