So this script is supposed to be something sort of like a mini-map, but for some reason it can't locate multiple enemies at a time, it only puts 1 enemy on the map at a time. Here it is:
local _FindCharacter = script.Parent.Parent.Parent.Parent.Parent.Character
function ClearMiniMap()
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") and v.Name == "Enemy" or v.Name == "Neutral" or v.Name == "Friendly" then
v:Destroy()
end
end
end
function enemyDetected(pos)
local x = game.Workspace:children()
for i=1,#x do
local xlist = x[i]
if xlist.className == "Model" and xlist~= script.Parent then
local islarm = xlist:FindFirstChild("Left Arm")
local ishuman = xlist:FindFirstChild("Enemy")
if islarm ~=nil and ishuman~=nil then
if (xlist.Position - pos).magnitude<50 then
return xlist
end
end
end
end
end
while wait(4) do
ClearMiniMap()
if _FindCharacter ~= nil then
local target = enemyDetected(_FindCharacter.Torso)
if target ~= nil then
if target.Detected == true then
local CopyEnemy = script.Parent.Storage.Enemy:Clone()
CopyEnemy.Parent = script.Parent
CopyEnemy.Position =(_FindCharacter.Torso.Position.x - target.Position.x), (_FindCharacter.Torso.Position.z - target.Position.z)
end
end
end
end
