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

How to smooth out a 'progress bar'?

Asked by 5 years ago

Hi there. I am trying to make a game similar to that of Mining Simulator as a school project. I've gotten some features down, but I am stuck on this one.

progress.Size = UDim2.new((cursorObject.Parent:FindFirstChild("Progress").Value/cursorObject.Parent:FindFirstChild("MaxHealth").Value),0,1,0)

The one above updates the GUI anytime the progress value changes.

cursorObject.Parent.Progress.Value = cursorObject.Parent.Progress.Value + damage
wait(1)

The one above is basically what is changing the value of the progress, constantly activating in a while loop, while mousebutton1 is being pressed.

Every time the GUI updates to match the progress value, it jumps to that value. This is expected. I am just wondering how would I smooth the transition out? Thank you.

1
You can use :TweenSize() to specify a customary transition type between the current position an the given UDim2 Ziffixture 6913 — 5y
0
If by smooth do you mean nicer/prettyer? moo1210 587 — 5y
0
Yea. By smoothing out I mean making it look appealing to the eye. Feahren, could you elaborate? Thank you! FierceLeviathan 10 — 5y

1 answer

Log in to vote
0
Answered by
moo1210 587 Moderation Voter
5 years ago
Edited 5 years ago

If you mean nicer/prettyer, you should use :Tweensize(). Here is a example the roblox wiki includes. It is a useful template to use so it should make it a bit easyer to change the settings.

local guiObject = script.Parent
local willTween = guiObject:TweenSize(
    UDim2.new(0.5, 0, 0.5, 0),  -- endSize (required)
    Enum.EasingDirection.In,    -- easingDirection (default Out)
    Enum.EasingStyle.Sine,      -- easingStyle (default Quad)
    2,                          -- time (default: 1)
    true,                       -- should this tween override ones in-progress? (default: false)
    callback                    -- a function to call when the tween completes (default: nil)
)

if willTween then
    print("The GuiObject will tween") 
else
    print("The GuiObject will not tween")
end

If this helped you be sure to Accpet the answer so we both get rep!

0
Wow. Thank you so much! It worked! I basically replaced the UDim2.new in the code you provided, with the one I provided. The animation works! I just need to make it quicker. Thanks to the both of you for helping me! Cheers! FierceLeviathan 10 — 5y
0
Your welcome. moo1210 587 — 5y
Ad

Answer this question