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

"TweenSize is not a valid member of UDim2"?

Im trying to make a very simple bar gui and decreasing as fuel for the object im scripting decreases. after encountering this problem i decided to do something very very simple, yet I still get the same error.

FuelLeft:TweenSize(UDim2.new())

I found another post on this site asking the same question, but the answer to that did not answer my question. Can I get some help when it comes to UDim2 constructors and how they rekate to GUI tweening?

1 answer

If I understand your question right, you just want a bar to resize like an hp bar? Having 100/100 hp wold be a full bar, 50/100 would be a half bar?

local Fuel = player.Stats.Fuel -- Define as the variable that stores fuel amount
local MaxFuel = player.Stats.MaxFuel -- Define as the variable that stores how much fuel you can have (or replace with a number)
Fuel:GetPropertyChangedSignal("Value"):Connect(function() -- Detect when players fuel changes
	local percentage = Fuel.Value/MaxFuel.Value -- Divide players fuel by players max fuel to get a number between 0-1. If you changed MaxFuel to a number, replace MaxFuel.Value with just MaxFuel
	FuelLeft:TweenSize(UDim2.new(percentage,0,1,0),"Out","Quad",.25,true) -- Tween the gui.
end)

2 comments

0

Hey, im so sorry for responding so late, I was busy for the past few days and count not get to a computer. Anyway, ive tried to impliment the code, yet I get the error "attempt to index number with 'GetPropertyChangedSignal'", any ideas?

0

That means you are defining Fuel as just a variable. You must define it as an actual NumberValue instead of just local Fuel = 100. Either that or you are trying to get the propertychangedsignal on Fuel.Value, instead of just Fuel.

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