Frame:TweenSize() Problem

I am making it so this line of code here:


makes the green frame
Screenshot 2020-10-07 174018
become smaller in size from right to left. However, the rest of the script runs fine EXCEPT for the tweening of this green bar.

I checked the hierarchy in the Explorer tab and everything is fine.

What is wrong with my code?

EDIT: If this helps:

abilityGUI is a ScreenGUI
MainFrame is a Frame with a UICorner
Bar is a Frame with a UICorner
SlidingPart is a Frame with a UICorner

1 Like

I don’t know exactly what you’re going to use to make the bar go up, but use that as a base:

abilityGUI.MainFrame.Bar.SlidingPart:TweenSize(UDim2.new(1, 0, 1, 0), "Out", "Linear", 0.5)

For example, in case it is a life bar:

local player = game.Players.LocalPlayer
local character = workspace:WaitForChild(player.Name)
local hum = character:WaitForChild("Humanoid")

abilityGUI.MainFrame.Bar.SlidingPart:TweenSize(UDim2.new((hum.Health / hum.MaxHealth), 0, 1, 0), "Out", "Linear", 0.5)
1 Like

The bar is supposed to go down as a “timer” like indication for how much time of the boost is left.

1 Like

Are there any errors in the output?

Can you tell me how you are storing the timer? it’s easier to explain knowing that

Edit: I’m sorry for the delay to answer too, I was thinking of a good way to do this

Nope, none that I can see regarding Tweening.

There didn’t seem to be any errors, the only problem is that you didn’t give a reason for it to change size

1 Like

Have no NumberValue or anything to store the timer?

1 Like

No, there isn’t a NumberValue. This is just a thing that Tweens, wait(), and then continue the rest of the function.

1 Like

Now I get it

A moment, I’ll think of a good way to do this

1 Like

Finally this is working lol
I never worked with timers that moved in descending order

But apparently it’s working…
image

local timer = 100
local timer_max = timer

local function updateBar()
	abilityGUI.MainFrame.Bar.SlidingPart:TweenSize(UDim2.new(timer / timer_max, 0, 1, 0), "Out", "Linear", 0.5)
end

spawn(function()
	for i = timer, 1, -1 do
		wait(1)
		timer = timer - 1
	end
end)

spawn(function()
	while timer > -1 do
		wait()
		updateBar()
	end
end)

If you don’t understand how something works, I can put notes and send it later. Thanks for your patience and sorry for the delay again.

Edit: Change the Timer value to what you prefer

1 Like

Thank you for the code! I greatly appreciate your hard work and dedication towards helping me.

1 Like

Your welcome, I’m happy to be able to help someone with a code for the first time

1 Like