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.
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.
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.
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.
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.