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

Can't seem to figure out how to add damage to my punch, Can anyone help me?

Asked by 4 years ago

So, I made this script where if I press (Q) it punches with an animation. Somehow, it won't do any damage at all, it only plays the animation.

CanDoDmg = true 
Keybind = "q" 
dmg = 10 


local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

mouse.KeyDown:Connect(function(key)
    if key == Keybind then
        local anim = script.Parent.Humanoid:LoadAnimation(script.Animation)
        anim:Play()
        script.Parent.RightHand.Touched:connect(function(hit)
            if hit.Parent.Humanoid and CanDoDmg == true then
            hit.Parent.Humanoid:TakeDamage(dmg)
            CanDoDmg = false
            wait(1)
            CanDoDmg = true
            end
        end)
    end
end)

Answer this question