I wanted to make a cooldown after being hit by an NPC. In this case its a zombie I scripted and animated. The animation works, it can follow a player, but when it damages the player instead of having a cooldown like I wanted it to have, it instead just kills the player in 1 second. Ironically the damage the npc gives towards the player is 10.
Here is a video showcasing what it is like in-game. https://www.youtube.com/watch?v=12MmcIdQ3CA&feature=youtu.be
I also tried to look up on the dev forum for answers but most were outdated or did not support my problem.
I don’t know what to add. I tried wait(2) but it just kills the player with all the damage after 2 seconds. Here is the code I used:
--local lhand = script.Parent.LeftHand
local rhand = script.Parent.RightHand
local function onTouch(otherPart)
local hum = otherPart.Parent:FindFirstChild("Humanoid")
if hum then
hum:TakeDamage(10)
end
end
lhand.Touched:Connect(onTouch)
rhand.Touched:Connect(onTouch)
Please help, I don’t know what to add.
What am I missing?