I made a punching animation but I am trying to make my animation do damage to dummies, but the animation wont play, and wont do damage! If anyone can tell me what I'm doing wrong that would help a lot.
My code:
player=game.Players.LocalPlayer
mouse=player:GetMouse()
function KeyD (key)
key=key:lower()
local hotkey=script.Hotkey
local char=player.Character
if key==hotkey.Value then
local dance=Instance.new("Animation")
dance.AnimationId="https://web.roblox.com/Punch-item?id=476354090"
local animloader=char.Humanoid:LoadAnimation(dance)
animloader: Play()
end
end
script.Parent.Touched:connect(function(part)
local human=part.Parent:findFirstChild("Humanoid")
if human then
if human.Parent.Name~=script.Parent.Parent.Parent.Name and
CanDamage == true and script.Parent.Parent.Swinging.Value==true then
CanDamage=false
human:TakeDamage(20)
wait(1.7)
CanDamage=true
end
end
end)
mouse.KeyDown:connect(KeyD)

5 comments
thanks man, sorry just started playing roblox like a week ago
do i put this script in the starter pack or?
Should function exactly the same as the one you posted, of which i assume was a tool?
Do I just put it in the tool?
Inside the handle or the part that you want to be the hit box for damage. Or you can put it directly in the tool and change line 25 "script.Parent.Touched:connect(function(Part)" to "script.Parent.Handle.Touched:connect(function(Part)"