Hello i am using the .Touched event to deal damage to players from a npc
here is my code
local HumanoidRootPart = script.Parent.HumanoidRootPart
local attacking = false
local function DamageFunc(humanoid)
print("runnning")
wait(1)
humanoid.Health = humanoid.Health - 10
attacking = false
end
local function Damage(player)
local h = player.Parent:FindFirstChild("Humanoid")
if h and attacking == false then
DamageFunc(h)
attacking = true
end
end
HumanoidRootPart.Touched:Connect(Damage)
But how would one delay an attack so that it only calls after the first attack finished? because the code i use now either just constantly attacks or stacks up.

1 comment
Use formatting