Script: local player = game.Players.LocalPlayer local db = true local damaged = false
local anim = Instance.new("Animation") anim.AnimationId = "http://www.roblox.com/asset/?id=4556329390"
game.players.localplayer.Character:waitforchild("righthand").touched:connect(function(hit) if hit.parent:findfirstchild("humanoid")and not db and not damaged and hit.parent.humanoid ~= game.Players.localplayer.character.humanoid then if game.Players.localplayer.character.humanoid.health > 0 then damaged = true game.ReplicatedStorage.Punch:FireServer(hit.parent.humanoid) end end end)
game:GetService("UserInputService").inputbegan:connect(function(input, event) if input.keycode == Enum.KeyCode.F and db then db = false local playanim = game.Players.LocalPlayer.Character:waitforchild("humanoid"):loadanimation(anim) playanim:play() wait(0.8) damaged = false db = true end end)
Try this:
local player = game.Players.LocalPlayer local db = true local damaged = false local anim = Instance.new("Animation") anim.AnimationId = "http://www.roblox.com/asset/?id=4556329390" player.Character:WaitForChild("RightHand").Touched:Connect(function(hit) local hitHumanoid = hit.Parent and hit.Parent:FindFirstChildOfClass("Humanoid") local playerHumanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid") if hitHumanoid and playerHumanoid and not db and not damaged and hitHumanoid ~= playerHumanoid and playerHumanoid.Health > 0 then damaged = true game.ReplicatedStorage.Punch:FireServer(hitHumanoid) end end) game:GetService("UserInputService").InputBegan:Connect(function(input, event) local playerHumanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid") if input.keycode == Enum.KeyCode.F and db and playerHumanoid then db = false local playanim = playerHumanoid:LoadAnimation(anim) playanim:play() wait(0.8) damaged = false db = true end end)