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

Changing a UDim2 Value?

Asked by 9 years ago

I'm trying to change the size of a Frame using a UDim2 value, and the problem is I want some values to remain constant. I'm also trying to use scale instead of offset, so the GUI fits universally.

Here's the script:

coroutine.resume(coroutine.create(function()
    time = fuel/10
    while not trigger and fuel < 100 do
        time = tick() - time
        fuel = time*10
        if fuel > 100 then fuel = 100 end
        fuelbar.Size = UDim2.new(fuel*2,0,Y,0) --I need a way to substitute the y-scale size value in for Y
        game:GetService("RunService").RenderStepped:wait()
    end
end))

2 answers

Log in to vote
0
Answered by 9 years ago

If I understand the question correctly, you want the Y scale size to be a constant. In that case, you literally substitute the Y with a constant, like so:

coroutine.resume(coroutine.create(function()
    time = fuel/10
    while not trigger and fuel < 100 do
        time = tick() - time
        fuel = time*10
        if fuel > 100 then fuel = 100 end
        fuelbar.Size = UDim2.new(fuel*2,0,0.2,0) -- Here, I replaced the Y with a constant,  in this case 0.2
        game:GetService("RunService").RenderStepped:wait()
    end
end))

0
I do want the y to be constant, but I want it to be the previous size of the UDim2 value. I figured it out myself though, thanks aquathorn321 858 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

I was able to answer my own question by digging a little deeper into the roblox wiki. The scale of a UDim2 value can be specified like so:

local v = UDim2.new(0,0,v.Size.Y.Scale,0)

Answer this question