Theres a few problems with my script
- The animation is spammable
- the player does damage just by walking up to a player when the right hand touches. But i want it to only do damage when the punch animation is played
canDoDmg = true
dmg = 25
local Plr = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://6203475027"
local track = Humanoid:LoadAnimation(Anim)
UserInputService.InputBegan:Connect(function(InputObject)
if InputObject.UserInputType == Enum.UserInputType.MouseButton1 then
track:Play()
script.Parent.RightHand.Touched:connect(function(hit)
if hit.Parent.Humanoid and canDoDmg == true then
hit.Parent.Humanoid:TakeDamage(dmg)
end
end)
wait(10)
end
end)

1 comment
This one does damage to the player just by walking up to them without playing the animation