local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")
function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 20
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:FindFirstChild("Torso")
human = temp2:FindFirstChild("Humanoid")
playerIdentifier = temp2:FindFirstChild'Player'
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) and playerIdentifier then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
if dist >= 10 then
script.Parent.Humanoid:MoveTo(script.Parent.Torso.Position)
end
end
if dist <= 5 then
local AttackMode = true
if AttackMode then
AttackMode = false
local Attack = script.Parent:FindFirstChild'ZombieAttackAnimation'
local animTrack = script.Parent.Humanoid:LoadAnimation(Attack)
animTrack:Play()
print'played'
wait(.7)
end
end
end
return torso
end
while true do
wait(0.1)
local target = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
script.Parent.Humanoid:MoveTo(target.Position, target)
end
end
yea i know thw wait() wakes the whole script stop but what can i substitute for wait but still have a debounce
