A bar for anything? (Urgent Advice Needed)

For my One Piece game I need some quick and snappy health bars, stamina bars etc. but am I able to make a “bar” for everything by just editing parts of a script? As I am not fluent in scripting I’m referring to a tutorial. But I can’t find how to make what I need:

A power bar:
A time limit on a power up such as ‘Gear 4’

An energy bar:
How much power is required in order to level up.

Not asking for full scripts here just small lines of code i could use to edit the already existing one
I’ll be leaving links and the actual code below.
Urgent advice needed.

You could use a module script and set the state of every bar in that script, then change the design or layout by calling from that module via local script

2 questions to follow up, would the module script be in the same area as the script
and also what would i put in the module script to specify what i want it to do

You can just change the size of the UI since it uses percentages e.g.
Udim2.fromScale(current / maximum, 1)

so by simply doing that i can have each bar have different functions?

For reference this will be like shindo life but one piece.

For example, you could observe if a property changed then change the size of the bar:

local MaxValue = 100

instance:GetPropertyChangedSignal("Value"):Connect(function()
	guiObject.Size = Udim2.fromScale(instance.Value / MaxValue, 1)
	
	-- Some other code that uses that instance's value maybe...
	-- if instance.Value then ...
end)

This is what the code from the YouTube video basically does except theirs listens for when a character’s health has changed. Bars like these would also need to have a maximum value in order to have a percentage. (50/100 is 50% and 3/4 is 75%)

1 Like

The .Changed event is different on a Value Instance compared to a normal Instance. The .Changed event on a Value Instance will fire when the Value changes and not when another property changes.

1 Like

the bars would be less of an event, more like a timer, for example.

The power bar would show how much power you have left of your transformation before you turn back into a normal human.

And the energy bar would record how much energy you must have in order to be able to transform.
Not recording health, stamina, etc.