I am trying to get this script to function when a zombie gets too close to a humanoid that has this script the humanoid will swing their weapon at the zombie, the only problem is that I don't know how to make the script target the zombies instead of players. After putting about an hours work into this I decided to come here for help, here is the part of the script that I am having trouble with
while true do
local p = game.Players:GetChildren()
for i = 1,#p do
if p[i].Character~=nil then
if p[i].Character:findFirstChild("Torso")~=nil then
if (p[i].Character.Torso.Position - script.Parent.Torso.Position).magnitude < 5 then
local anim = Instance.new("StringValue")
anim.Value = possibleAnims[math.random(1, #possibleAnims)]
anim.Name = "toolanim"
anim.Parent = script.Parent.LinkedSword
end
end
end
end
wait(0.5)
end

1 comment
Why is your tabbing so bad?