As the title says, I am having trouble making it debounce. Thank you for helping me.
ply = game.Players.LocalPlayer
repeat wait() until ply.Character
char = ply.Character
mouse = ply:GetMouse()
local debounce = false
local CanDamage = false
anim = {
equip= "rbxassetid://1007180526",
leftpunch = "rbxassetid://1007372513",
}
equip = Instance.new("Animation", char.Humanoid)
equip.Name = "Equip"
equip.AnimationId = anim.equip
lpunch = Instance.new("Animation", char.Humanoid)
lpunch.Name = "LeftPunch"
lpunch.AnimationId = anim.leftpunch
combat = false
function combats()
local ran = math.random(1)
if ran == 1 then
char.Humanoid:LoadAnimation(lpunch):Play()
end
end
function key(key)
key = key:lower()
if key == "2" and combat == false then
print("hi")
equips = char.Humanoid:LoadAnimation(equip)
equips:Play()
combat = true
elseif key == "2" and combat == true then
equips:Stop()
combat = false
end
end
enabled = true
function punch(key)
if combat == true and enabled == true then
combats()
enabled = true
end
end
mouse.keyDown:connect(key)
mouse.Button1Down:connect(punch)

1 comment
Mouse.keyDown is deprecated. Use userinputservice or contextactionservice instead