How would I go about a custom health system?

Hi, I’m looking to make a health system similar to ones in games like Super Mario Galaxy, A Hat in Time, etc., but I have little experience in scripting and have no idea where to start.

Here’s basically what I think I need to do:

I need the script to identify how much health the player has through humanoid.health.
If the player has full health, display the image that shows full health. If 75%, show image for 75, etc

Here's what the gui looks like

health1 health2 health3 health4

these are temporary

How would I go about this? Where should I start?

1 Like

Start with a server script and assign each player a health value.

local Health = {}
-- then when a player joins:
Health[Player.Name] = {Health = 4} -- default value
-- when a player takes damage
Health[Player.Name].Health = Health[Player.Name].Health -1
 -- do a check to see if the player should be dead
 --Send to client with a number so that you can update their UI accordingly.

And pretty much just build on this system.

3 Likes

I’d probably do something similar to @MineDevs however I’d keep a Health IntValue inside a Stats Folder in the player.

It just makes things much easier to work with, rather than having to Fire a bindable/remote to a script to get a value.

1 Like

Much nicer method, I only started doing my server only method because I noticed giving exploiters too much information about other players can result in bad things.

For example: Exploiter does a loop and checks who is on 1 health and instantly teleports and kills them. Just an example.

Make your decision based on this.

3 Likes

whats stopping the exploiter from just doing Character.Humanoid.Health <= 1

I don’t think you read this post right. They were talking about Intvalues, and tables to store health, Not actully health in a humanoid. And that these values would be stored in the server, and not the client, making them slightly harder for exploiters, (Not impossible, just harder).

Also, try not to revive posts that are a couple of years old, as some methods of exploiting (for your case, have changed since 2020)