remoteFolder.damageinflicted.OnServerEvent:Connect(function(inflicter,reciever,amount)--inflicter = player instance, reciever = character model
reciever.Humanoid.Health -= amount
if reciever.Humanoid.Health <= 0 then --this doesn't work?
inflicter.leaderstats.elims.Value += 1
end
end)
The remote event, parameters, and health deduction all work perfectly. However, for some reason the if statement doesn’t fire whenever the reciever’s health equals or goes below 0 from the previous line
If I could get some help with this that’d be great ;]
The only reason why the if statement won’t run is because the logic is false. And the only reason why the logic would be false is because the player’s health isn’t actually at or below 0, indicating that the player was never killed, which is why I draw the conclusion that your method of inflicting damage is NOT GOOD
^You can see both clients and the server see the damage. No replication issues…
I don’t know why you don’t believe me when I say the damage infliction works. Stop being a jerk about it too. The logic isn’t “false”. And it’s not “my method”, I’m curious as to why Humanoid.Health <= 0 doesn’t work
I’m not being a jerk, I’m literally explaining to you why the if statement fundamentally doesn’t work, which IS because the logic is false, BECAUSE the player’s health literally isn’t at or below 0
What I’m saying is that the if statement should and only should run when the player dies. Yes, in that screenshot, that other player took damage but he didn’t die! So can you check to see what happens when you kill him?
If you want to do a leaderboard kill system, You could instead tag the receivers humanoid for (x) seconds then a seperate script in the receiver checks if his humanoid has died with a tag
Then, I’m gonna be honest with you, I have no idea what went wrong. I told you the exact reason as to why the if statement wouldn’t work, and that’s all I have to say
Do you mind sharing the place file with us so we can test it too?
I made a copy of the place and Humanoid.Health <= 0 worked in it… restarted the non-copy and now it works too
i probably should’ve thought about restarting studio first…
Consider listening for the “.Died” event to fire on that “Humanoid” instance instead as it’s the correct/proper way to go about waiting/detecting a humanoid’s death.