What do you want to achieve?
I want to make a good health system with defense and shields in the best way without breaking any guis
What is the issue?
I’m not sure what the best way is, either 1: Making damage calculations before damaging the player (more work), or 2: Having a .HealthChanged function that takes the raw damage then reduces damage if the player has defense or shields, or 3:Making a new health int value and using that value for damage dealt, and having a script doing calculations based on the int value then changing the humanoid with the calculations.
Also, I have a health gui (local):
humanoid.HealthChanged:Connect(function(damage)
healthbar.Size = UDim2.new(humanoid.Health/maxhealth,0,1,0) -- im going to tween this
healthnumber.Text = humanoid.Health
end)
If I did method 2, then my health guis would go up and down, which would look weird.
What solutions have you tried so far? I have searched for the best health system, but I am still confused. My game is going to be about weapons and magic attacks that deal damage, and some will have defense/shield buffs that will be values. I don’t know the best way to make a health system including defense and shields, and this is important to me as I think starting off the best system is going to have less work.
Making a good health system can be tricky at times especially when it comes to calculating hits and damage. My best advice for making it so that it deals less damage by having shields or powerups is to get the raw amount, as you said and get a script to check the player’s data to see if they have set items.
Damage with UI’s, etc.
The best way to do this without making it too overly difficult and overcomplicated is by just reducing the player’s damage on hitting, etc BY having a powerup or a certain shield that blocks a certain amount. But to also just change the information into a UI as well, and that is why the .HealthChanged function is so useful in terms of calculating damage. You can calculate the damage dealt(expected) by giving the scripts information about what the weapon does, etc. The best way, as I said to input it as ui form is to just give the scripts information about what the player has, what damage is being delt(expectedly) and what the player is doing to deal more or less damage.
I hope that helps and I’m sorry if I make no sense lol.
Sorry I don’t understand well, what method are you saying? Are you saying to have raw damage impact, then calculate after when the script finds the player taking damage, or to calculate the damage before its impacted on? Sorry I don’t understand.
I am going to try method 3. Do you think it is a good method? Making a new value on the player then having damage effect that value then a script detecting the value change and doing calculations before damaging the humanoid.