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

UDim2 Resize Help?

Asked by 9 years ago

16:23:33.954 - Players.Player.Backpack.Mainframe:132: attempt to perform arithmetic on a userdata value fgui.GUI.Size = UDim2.new(0.3, 0, 0.02, 0) * (Fuel/MaxFuel)

0
Could you post the script in question? Pyrondon 2089 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

So you are making a bar that changes size depending on the amount of fuel?

Here is a better way of doing what you were doing:

Hierarchy

  • ScreenGui
    • BarHolder (size of the bar)
      • Bar (what you resize)
    • Script

LocalScript

local maxFuel = 100
local fuel = maxFuel

while wait() do
    script.Parent.BarHolder.Bar:TweenSize(UDim2.new((1/maxFuel) * fuel,0,1,0),"InOut","Quad",0.1,false) -- this is for a bar on the X axis, not the Y, to have it on Y, simply change the first argument to 1
end

This is for a length wise bar , not height wise. To change, simply swap the first argument of UDim2.new() with the third.

Tweens change the size/position of a gui smoothly.

Ad

Answer this question