I have a function here:
local function damageHandler(dmg, victim, player)
print(dmg)
local v = game.Players:GetPlayerFromCharacter(victim)
local p = game.Players:GetPlayerFromCharacter(player)
local bonus = p.Bonus.Value
local Defense = v.Defense.Value
local died = false
if (victim.Humanoid.Health - dmg+(dmg*bonus/100)-(dmg*Defense/100)) <= 0 then
v.leaderstats.Fissions.Value += 1
p.leaderstats.Disrupts.Value += 1
died = true
end
victim.Humanoid.Health -= (dmg+(dmg*bonus/100)-(dmg*Defense/100))
print(dmg+(dmg*bonus/100)-(dmg*Defense/100))
print(dmg)
print(victim.Humanoid.Health)
end)
and when I use this
if Electrolysis.Value == 100 then
damageHandler(15,hit.Parent, char)
else
damageHandler(5,hit.Parent, char)
end
both print 15 for each print besides when there is defence and bonus, but it still applies 15 to the dmg value no matter what.
then in another connection I have
if Electrolysis.Value == 100 then
damageHandler(25,hit.Parent, char)
else
damageHandler(15,hit.Parent, char)
end
but it’s printing 20 instead
Anybody know what’s happening?