Hello, I’ve been experimenting with a few different ways to create a health bar for my mining system but I seem to be getting a few common problems with each one so I wanna ask a question.
Developers, how do you make a secure health bar that is efficient and won’t have a bunch of problems that make the game look worse then when there wasn’t a health bar?
Also some clarification for the DevForum gurus, I’m not asking for a full script, just some guidance.
And for more clarification, the health bar is for the rock the player is currently mining.
Try to review the code for the old Roblox health bar:
HealthScript v3.1.rbxm (4.6 KB)
(Place in StarterCharacterScripts)
This health bar runs on the server, so it is quite secure as well. I recommend reviewing the code for it.
Hey, I reviewed the script you sent but there isn’t much I can gather from this.
health bar…?
mining system?
as in like, a health bar for the block youre mining? if thats what you mean, then i have two ideas (that could be combined if you wish)
- a billboard gui above the rock you are mining that only shows up when you hit it and fades away afterwards
- a visual indication such as cracks in the rock that appear
as far as making an actual health bar goes, its pretty simple, should just need to look up a video tutorial to get the gist of it
basically you have a background and a the moveable bar, then when the value changes you tween the bar’s size to like the value/background size or something
1 Like
How would I check to see if the player has not hit the ore in a given amount of time so I can make it fade out? Is there a specific check?
well when the player hits the block and you make it appear, wait, say, 2 seconds until it disappears
wait(2)
--make block disappear
then, of course, if the player hits it again, restart the timer- one way of doing this is instead of having a wait, we can have a for loop,
local secondsBeforeUIFades = 2
for i = 1, secondsBeforeUIFades do
wait(1)
end
and then every loop through, check if the value of the block’s health has changed (meaning the player has hit it), and reset the timer:
local secondsBeforeUIFades = 2
for i = 1, secondsBeforeUIFades do
if blockHealthValue < previousBlockValue then
i = secondsBeforeUIFades
end
wait(1)
end
of course set blockHealthValue and previousBlockValue as variables for what they sound like
also, im not entirely sure if you can manually change the value of “i” in a for loop, but if you cant, then i guess make the for loop a function, then just call the function again to reset it when you need to?
1 Like
I’ll be trying this tomorrow. Thank you!