Hello, I’m working on a radar System that catches everything witch the class ‘Humanoid’ around the player.
Using a loop to filter all humanoids in workspace doesn’t sound a good idea, even because each player have a radar system. I think it can slow game performance significantly. The Minimap shows where exactly are the Humanoids Position, even if the Humanoid moves.
There is a way to improve it?
how the minimap looks like (sorry about the bad quality)
the red dots appear on the minimap when Humanoids are next to the player and disappear when far enough.
and the main script:
function Radar()
while wait(.5) do
for i,pilotsOnRadar in pairs(workspace:GetChildren()) do
if pilotsOnRadar:IsA('Model') and pilotsOnRadar:FindFirstChild('Head') and pilotsOnRadar.Name ~= player.Name then
local target = Instance.new("Part")
local pos = pilotsOnRadar:GetModelCFrame().p
if player:DistanceFromCharacter(pos) <40 then
-- I use "alienId" to differentiate them because there are a loot of enemy with the same name
if not viewPort.Pilots:FindFirstChild(pilotsOnRadar.Configuration.AlienId.Value) then
if pilotsOnRadar:FindFirstChild('Alien') then
target.Color = Color3.fromRGB(135,0,0)
end
target.Name = tostring(pilotsOnRadar.Configuration.AlienId.Value)
target.Size = Vector3.new(15,0.05,15)
target.Anchored = true
target.CanCollide = false
target.Parent = viewPort.Pilots
end
viewPort.Pilots:FindFirstChild(pilotsOnRadar.Configuration.AlienId.Value).Transparency = 0
target.CFrame = (pilotsOnRadar.HumanoidRootPart.CFrame)
print('Radar Catch: '..pilotsOnRadar.Name)
--if not in the range
elseif viewPort.Pilots:FindFirstChild(pilotsOnRadar.Configuration.AlienId.Value) ~= nil then
viewPort.Pilots:FindFirstChild(pilotsOnRadar.Configuration.AlienId.Value).Transparency = 1
print(pilotsOnRadar.Name..' Out of Range')
end
end
end
end
end
spawn(function()Radar()end)
and the script perfomance: