Hi i am a new scripter. I have very limited scripting knowledge
I am making a zombie game, My script kinda works…
When the zombie hits the player the player gets damaged, If the zombie hits the player the second time the player does not take damage.
Also there is nothing in the output.
I think this is the part of the script to do with the attacking, if it is not, willing to provide the other parts of the script.
local humanoid = mob.Zombie – Zombie is the humanoid but renamed so zombies don’t damage each other
humanoid.Touched:Connect(function(hitPart)
if not isAttacking then return end
local character = hitPart.Parent
if character:FindFirstChild("Humanoid") then
isAttacking = false
character.Humanoid:TakeDamage(damagePerHit)
end
if not isAttacking then return end
local character = hitPart.Parent
if character:FindFirstChild("Humanoid") then
isAttacking = true
character.Humanoid:TakeDamage(damagePerHit)
end
Oh you have to do it AFTER the character does damage, so you would basically have both.
if character:FindFirstChild("Humanoid") then
isAttacking = false
character.Humanoid:TakeDamage(damagePerHit)
wait(CooldownNumberToPutBeforeItCanHurtAgain)
isAttacking = true
end
if closestCharacter then
humanoid:MoveTo(closestCharacter.HumanoidRootPart.Position)
if not isCoolingDown and (closestCharacter.HumanoidRootPart.Position - mob.HumanoidRootPart.Position).Magnitude <= hitRange then
isCoolingDown = true
attackAnimation:Play()
isAttacking = true
attackAnimation.Stopped:Wait()
isAttacking = false
wait(hitCooldown)
isCoolingDown = false
end
end