Checking the humanoid's health is not working

When I run this it always prints 1 (meaning full health) no matter how much health I have, anyone know why? I can’t figure it out, also when I print just the health (not divided by max health) it always says 100

1 Like

You’re printing the health variable of which it equals 1 (100 divided by 100 is equal to 1).

I’m printing the player’s health divided by the player’s max health and even when the health variable is at like 10 and not at 100 it still prints 1 is my problem.

I’d assume that if it is continuously printing 1 while you’re printing division, the numbers you’re using are likely equal to each other. Also, if you’re changing health from client-side - if I’m not mistaken - it will only apply to the client, not the server.

By default your max humanoid health is 100, and your current health is also hundred. You don’t change the max health until after the print statement is called and your dividing 100/100.
Print max health and health before your first print statement and you’ll see.

If you change your max health BEFORE you calculate health then it should work. Also couldn’t you just do hum.Health?

Also as stated above, make sure you change this from the server.

I’m trying to get the health/maxhealth before the maxhealth changes because I want to change it back after 15 seconds so if I changed max health before I calculate then the numbers wouldn’t be right. I have tried just using hum.Health but it also prints 100 no matter what health I’m at. So the main problem is getting the humanoid’s health always thinks it is at max health

I don’t quite get to what your trying to do. If you want a custom max health, define it at the top of the script, do your calculations, wait 15 then just change it back to normal?

If you don’t change it then you’ll always get 1 as 100 your maxhealth divided by your normal health (100) it should always return 1.

that’s what I am doing but it always says the humanoid has max health no matter what

That’s cause you start with maxhealth on spawn. Maybe damage the player then run your script?

It’s running after you click on a tool so I damaged the player before running the script already

Just a question, are you damaging the player serversided?

Also I still don’t get the point of all this. The health should automatically change depending on the max health. If you get damaged 20, your health should be 80/100…

Yes I am damaging the player serversided

Let me get this straight, when the tool event is fired, it damages the player and you want it to print the player’s current health?

That’s what I’m trying to do so I can make the player have higher max health but then return to normal after except it won’t get the humanoids health it just always prints that it’s at 100 health

Can you show me the tool script that you are damaging the player from? And is this a local script and server script, and also where.
If it was server sided it should be damaging the player.

If you want to increase the player’s health everytime it is hit, you can get the hum.MaxHealth and increase by + whatever.

Afterwards you can just wait a bit and set the max health back to 100.

I added the damage part to when you click the tool and this is a server script but I also want the health to keep the same ratio to the max health when the max health goes up

Like I said please send the tool script.

So if you get damaged 20, your max health goes to 120 and your normal health goes to 120 also?

We are dragging the post pretty far so please contact me on discord: Synth#4445

rewrote all the code that checked your health and it was fixed

1 Like