#humanoid:takedamage() doesn't apply damage

1 messages · Page 1 of 1 (latest)

trail musk
#
ApplyDamage.EnemyAttack = function(_, Damage, PlayerInfo, Knockback, AttackId)
    local PlayerModel = PlayerInfo[1]
    local UnitVector = PlayerInfo[2]
    local PlayerHumanoid = PlayerModel:FindFirstChildOfClass("Humanoid")
    local PlayerRoot = PlayerModel:FindFirstChild("HumanoidRootPart")
    local AttackIds = require(PlayerModel.AttackIds)
    local ValidAttack = table.find(AttackIds, AttackId)
    
    print(AttackIds)
    
    if table.find(AttackIds, AttackId) then
        print("Same attack id, cancelling damage")
        return
    else
        table.insert(AttackIds, AttackId)
        task.delay(1, function()
            table.remove(AttackIds, AttackId)
        end)
    end
    
    print("Applied Damage")
    warn(PlayerHumanoid:GetFullName())
    PlayerHumanoid:TakeDamage(Damage)
    
    if Knockback == 0 then return end
    
    local Player = Players:FindFirstChild(PlayerModel.Name)
    KnockbackPlayer:FireClient(Player, Knockback, PlayerRoot, UnitVector)
end

anybody know why takedamage doesn't work? the knockback event fires even when the damage doesn't do anything.
the humanoid is parented under my character btw

compact jolt
#

any errors?

trail musk
#

nope

compact jolt
#

did you try printing PlayerHumanoid and see if its a humanoid

trail musk
#

yeah i printed the full name too

compact jolt
#

so you are sure you are refering to the right player

trail musk
#

yeah

compact jolt
#

did you try to manually remove health from the humanoid

trail musk
#

it sometimes deals damage but only like half the time

#

even when the knockback happens

compact jolt
#

could it happen that the variable Damage is half the time 0?

trail musk
#

lemme check

#

nope, prints as 8

compact jolt
#

idk any other scripts that could heal him up immediatly after or something like that

trail musk
#

nope

#

it might be a studio bug because another bug popped up with something that i didnt change

compact jolt
#

wdym

trail musk
#

roblox studio gets updates a lot, some of which might have bugs

#

theres already been an instance of a bug causing a ton of lag iirc

compact jolt
#

ive never ran like once into an bug in like 6 years of scripting ur bug is somewhere in the PlayerModel or Damage Variable

trail musk
#

alr i'll check later gonna eat dinner