I KNOW KEYDOWN IS DEPRECATED
Hi, I made an animation where I give a punch. Now, I'd like to give damage when a player or an humanoid get's hit by it. I tried this, not working though.
local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
local db = false
local anim = Instance.new("Animation")
local damage = game.ReplicatedStorage.Damage.Value
anim.AnimationId = "http://www.roblox.com/asset/?id=2055511545" -- id of animation
mouse.KeyDown:connect(function(key)
if db == false then
if key == "q" then
db = true
local playAnim = humanoid:LoadAnimation(anim)
playAnim:Play()
wait(1)
db = false
game.Players.LocalPlayer.Character.RightHand.Touched:Connect(function(plr)
local huma = plr:WaitForChild("Humanoid")
if huma then
huma.Health = huma.Health - damage
end
end)
end
end
end)

1 comment
If you know KeyDown is deprecated, why are you using it?