How do I get my ScreenGui to work properly?

I’ve been trying to create a ScreenGui cooldown animation. It does play, however the bar expands downward when it plays. How do I make it so that it stays in line with the grey line and the rest of the white line?

The function:

script.Parent.Activated:Connect(function()
    if activated == false then
        activated = true

        --cooldown animation
        cooldown_gui.Enabled = true
        cooldown_gui.Parent = player.PlayerGui

        whiteBar:TweenSize(UDim2.new(0, 0, 1, 0),"Out","Linear",cooldown)
        whiteStart:TweenPosition(UDim2.new(-0.334, 0, -0.8, 0),"Out","Linear",cooldown)
        wait(cooldown)
        cooldown_gui.Enabled= false
        whiteBar.Size = UDim2.new(0,801,0,43)
        whiteStart.Position = UDim2.new(0.802, 0, -0.8, 0)

        activated = false
    end
end)

Screen:
https://gyazo.com/cf7c3a8a2b676cc27ce13911025459be

what is whiteBar and whiteStart?

whiteBar is the main “line” bit which shrinks, whiteStart is the dot which is just for aesthetic purpose, and it works fine. the whiteBar is the one which is expanding downwards

i need the whiteStart though, you can just ignore that bit of the code as it works fine

Use the scale, 1,0,1,0 is full and 0,0,1,0 is empty

https://gyazo.com/e86a06c046354e1784e8c1daddce0682

still doesn’t work

I think you made this harder than it should be. You can have 2 frames consisting of UICorners. One frame which would be the bar we would tween (white bar) parented to the other (gray background bar). The gray bar’s size can be in offset or scale. The white bar we would tween’s size would be (1, 0, 1, 0) and position would be (0, 0, 0, 0). Then you could tween the white bars size down to (0, 0, 1, 0).

I created a game as an example, you can look at the scripts and apply it to your game
(do not copy)

Bar.rbxl (31.7 KB)

that works, thank you so much!

1 Like