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

[SOLVED] How do I make the UI tween from left to right?

Asked by 3 years ago
Edited 3 years ago

I don't know how to make the UI tween from left to right depending on the value of "CurrentEnergy"

-- Energy --
local CurrentEnergy = char:WaitForChild("CharacterManagement"):WaitForChild("CharacterStats"):WaitForChild("Energy")
local MaxEnergy = char:WaitForChild("CharacterManagement"):WaitForChild("CharacterStats"):WaitForChild("MaxEnergy")
------------

CurrentEnergy:GetPropertyChangedSignal("Value"):Connect(function()
    local healthChange = CurrentEnergy.Value/MaxEnergy.Value
    healthGui.EnergyBarUI.MainEnergy.AnchorPoint = Vector2.new(0.5, 0.5)
    healthGui.EnergyBarUI.MainEnergy:TweenSize(UDim2.new(healthChange,0,1,0),"In","Sine",0.05)
end)

This is what happens when I attempted to have the UI trying to go left to right: https://media.discordapp.net/attachments/833569929696509972/878152211182530570/BiggestFail.PNG

3 answers

Log in to vote
0
Answered by 3 years ago

Use anchorpoint. Set it to 1,0,0,0 and then it will increase towards the left and decrease towards the right, which is flipped.

0
@AlexanderYar I tried to do that, but it keeps disappearing to the left. I'm not sure on what to do. TheBuliderMC 84 — 3y
0
I mightve misundersrood your question AlexanderYar 788 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

change

UDim2.new(healthChange,0,1,0)

to

UDim2.new(0,healthChange,0,1)

because you change offset it wont work, so you must change scale.

Log in to vote
0
Answered by 3 years ago

I just found out it was so simple... I just had to make "EnergyBarUI" Rotation 180 inorder to make it go left to right.

Answer this question