I want this script just to work when I have the "Combat" tool equipped. The script worked before I added line 13. So how can I make it work?
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local Animation = character:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("Animation"))
local Damage = 5
local Debounce = 0.3
local Keybind = Enum.UserInputType.MouseButton1
local CanPunch = true
player.Backpack:WaitForChild("Combat").Equipped:Connect(function()
UserInputService.InputBegan:Connect(function(input,busy)
if input.UserInputType == Keybind and not busy then
if CanPunch == true then
CanPunch = false
Animation:Play()
Animation.Looped = false
game.ReplicatedStorage.Remotes.Punch:FireServer(Damage)
wait(Debounce)
CanPunch = true
end
end
end)
end)
