Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix acessory ruining my combat error?

Asked by
Nozazxe 107
3 years ago
Edited 3 years ago

Hello. I made a combat system and when i hit people it works. But, when i hit someones acessory, it stops working and says there is no humanoid in the players acessory. If i make the script to hit the parents parent, then it wont work unless i hit the acessory. If i dont, i still cant hit the players with acessories. Can someone help?

local canPunch = true
script.Parent.Handle.Touched:Connect(function(hit)
    if canPunch == true then
        canPunch = false
        local hum = hit.Parent.Humanoid
        if hum.Parent ~= script.Parent.Parent then
            hum:TakeDamage(10)
            wait(1)
                canPunch = true
            end
        end
end)


Answer this question