Custom health bars, stamina bars and how to handle them?


I’m trying to code a custom Health bar, Stamina bar and Strength bar in my game.
Here’s what they look like for context:

The issue is that up till now I have only been working with the camera, gui’s and animation which aren’t really exploitable. I would like to make them as secure as possible from the get go.

A basic idea I have is to handle the animations of the gui locally and set the values of the Player (health, walkspeed) from the server. I have looked into remote events and functions but I didn’t understand them fully yet so I would appreciate if someone knows some resources worth looking into for this scenario or maybe a different way to handle it.

Thank you in advance!

Do you need help with making the the bar fill and “unfill”?

What I want to know is how could I make it less exploitable. For example, at first I thought of doing everything in a local script, but players could mess with the values inside that and achieve speed hacking

The filling and unfilling is not of concern since I could just use a tween when the player starts and stops sprinting

1 Like

You can’t do much with the client exploiting their health bar value. However, you should always validate and apply damage on the server to determine if a player should take damage or not.

The health bar should just point at the humanoid’s health. When the server overwrites the health property, that’s what everybody else will see as well.

1 Like

What about the Stamina value, shouldn’t the player in theory be able to achieve infinite sprint if they mess with the variables in the script, because I wouldn’t want them to do that, since it would ruin a lot of the gameplay for other players.

You can go two ways about achieving this.

1 (Which I don’t recommend)

  • Constantly have the server manage a player’s sprint by sending a RemoteEvent to activate and deactivate the sprint. I don’t recommend this since server latency can become a problem for the general experience.


  • Have the server check every X amount of seconds how long the player has been running for past the normal WalkSpeed. Lets say at most, a player can sprint for 8 seconds. But the server detects a speed that lasted for 10 seconds. It’s safe to assume the player is cheating. Then, you can act however you’d like.
1 Like

Thank you, I’ll try both ways and test them out and see which fits best on the long run

1 Like