There is nothing wrong with the animation. Only the damage part is wrong
player = game.Players.LocalPlayer animation = script:WaitForChild("Animation") enabled = true ra = player.Character:WaitForChild("Right Arm") dmg = script.Damage.Value game:GetService("UserInputService").InputBegan:connect(function(input,proc) if input.KeyCode == Enum.KeyCode.Q then if enabled then enabled = false function onTouch(ra) local humanoid = ra.Parent:FindFirstChild("Humanoid") --Im not sure if the humanoid is being properly indentified if humanoid ~= nil then humanoid.Health.Value = humanoid.Health.Value - dmg -- Where the damage won't work end ra.Touched:connect(onTouch) end local animationTrack = player.Character.Humanoid:LoadAnimation(animation) animationTrack:Play() wait(0.5) enabled = true end end end)
Well, you've got a couple of them, not as bad as I've seen. You're trying to connect to a function with the connection line inside the function. With this, the function will never get called.
Also, having the onTouched
function inside the InputBegan function will just keep recreating that event meaning your punches will quickly get stronger.
What I've done was move the connection line out of the function. And moved the function out of the InputBegan connection function.
player = game.Players.LocalPlayer animation = script:WaitForChild("Animation") enabled = true ra = player.Character:WaitForChild("Right Arm") dmg = script.Damage.Value game:GetService("UserInputService").InputBegan:connect(function(input,proc) if input.KeyCode == Enum.KeyCode.Q then if enabled then enabled = false local animationTrack = player.Character.Humanoid:LoadAnimation(animation) animationTrack:Play() wait(0.5) enabled = true end end end) function onTouch(ra) local humanoid = ra.Parent:FindFirstChild("Humanoid") --Im not sure if the humanoid is being properly indentified if humanoid ~= nil and enabled == true then humanoid.Health.Value = humanoid.Health.Value - dmg -- Where the damage won't work end end ra.Touched:connect(onTouch)