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
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%)
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.