Player doesnt die if health gets damaged negitive 0 [closed]

Im currently working on a game right now, and i am suffering from a bug.
Apparently, if a player takes damage below 0, it will display as a negitive number, basically making the player unkillable.

Heres a video for refrence


If anyone can give me advice, I would appreciate that.
It seems like the tool guns I used apparently sometimes will take negive damage even if the players health is below zero.

is the damage given on client side (through local script) or server side (serverscript)?

If you are using Humanoid:TakeDamage() instead use:

Humanoid.Health-=Damage

Ive had situations where using take damage would not trigger death on a humanoid that would normally die when reaching <=0 HP

Alr, ill try to modify my gun scripts to fit that require. Ill see what i can do.

If you want to have a max of 100 damage you can do like this:

local Player = path.to.player
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChild("Humanoid")

Humanoid.HealthChanged:Connect(function()
   local currentHealth = Humanoid.Health

   currentHealth = math.clamp(currentHealth, 0, 100)

   Humanoid.Health = currentHealth
end)

If you want the player do not to that much of a damage (under 0) just clamp their damage.

The gun damage is done through a local script.

It fixed the negitive health isusues, npcs seem fine. But im still having issues with players. I’ll send a video of my results.
Take a look.

That’s bad practice, stuff that you want other players to see need to be on serverscripts not localscripts.

Anyways whatever, i tried uploading the video, nothin happen.
It was baiscally saying i tried changing the text from hithumanoid:damage to, hithuamnoid.health-=damage.
And apparently, it works for npcs, but my side, when i kill a player “my alt” with the gun, he dies and falls apart like normal. But on my alt’s screen, hes in 1 peiece. Even the death sound tries to play 3 times, not like i asked the assistant to make 4 scripts on making sure the player is dead after negitive health. I am so confused, like I’ve tried making my own roblox guns in the past, but how could I be so wrong using a highly rated “96%” freemodel, modifiying it, and leaving it as that. I found some line of code that I changed in the “Handgun” local script.


To what you said to change it to.
And it worked for the test npc, not for my alt.
I have no idea. I tried, and I failed.
And now im outting myself for using freemodels in my builds, even though I am good at building, but not really scripting or tool building.

I dont care if people call me a free to play for using free models, its just a shortcut. Now im at sqaure 1.

If someone could give advice, I would accept
But for now I am still trying to fix this issue. I’ll try to take any advice givin.

You could just use an if statement, so:

hitHumanoid:TakeDamage(Damage)
if hitHumanoid.Health <= 0 then 
    hitHumanoid.Health = 0
end

And if that doesnt work

hitHumanoid:TakeDamage(Damage)
if hitHumanoid.Health <= 0 then 
    hitHumanoid.Parent.Head:Destroy()
end

And I would still listen too those other devs, if they say its bad practice dont do it. They have a lot more knowledge than you, and your not gonna go anywhere in your development journey if you refuse to listen to the advise of others.

1 Like

I’ll try that. Hopfully this will fix it, I’ll just keep trying and do what I do.


I tried the changes on the handgun, same result.
Also the handguns crosshair broke/the gun broke and was unusable.

Crosshair exampe:


I probably should try rethinking how I add tools/weapons to my game.
I dont need to brag about my skills, I develop games as an hobby. How would I get my joy with no experience and using broken free models from the catalog.
I have no words.
There is no way this is gonna contiue.
I’ll have to get some other means of help or ideas.
I DONT KNOW.

Great job, realized I’m a terrible developer.
I guess I’ll try next time.
I mean, I’ll just try stepping up my coding skills?

1 Like

You’re not a terrible developer, anyways have a nice day and I hope your game goes well.

1 Like

Okay, I did ended up fixing the issue, but in a different manner.
I dont need to explain, It’s late, and I must rest.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.