Help with radar not finding humanoids in workspace model

Hey there,

Recently, I wanted to create a Radar for one of my games, but there’s a problem. The radar gets other players correctly, but I want it to only get the HumanoidRootParts inside of a specific model in workspace, but everytime I’ve tried to do so, it either breaks fully, or displays wrong.

Could anyone help me fix this or solve this little issue?
Thanks!

local playerDotTemplate = script.PlayerDot
local radarBG = script.Parent:WaitForChild("Background")

local Player = game:GetService('Players').LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

while true do
    wait(2.5)
    
    for i, v in ipairs(script.Parent.Background:GetChildren()) do
        if v:IsA("ImageLabel") and v.Name == "Radar_Image" then
            
        else
            v:Destroy()
        end
    end

    local uiAspectRatioConstraint = Instance.new("UIAspectRatioConstraint", radarBG)
    local ui = Instance.new("UICorner", radarBG)
    ui.CornerRadius = UDim.new(1, 0)
    
    for i, otherPlayer in pairs(game.Players:GetPlayers()) do
        
        local otherChar = otherPlayer.Character
        
        if otherPlayer ~= Player then
            if otherChar and otherChar:FindFirstChild("HumanoidRootPart") and Character:FindFirstChild("HumanoidRootPart") then
                
                local playerDot = playerDotTemplate:Clone()
                playerDot.ImageColor3 = Color3.new(1, 0.203922, 0.203922)
                
                
                local offset = otherChar.HumanoidRootPart.Position - Character.HumanoidRootPart.Position
                
                local distance = 1/200
                offset = offset * distance
                playerDot.Position = UDim2.new(offset.X + 0.5, 0, offset.Z + 0.5, 0)
                
                
                playerDot.Parent = radarBG
            end
        else
            
            local playerDot = playerDotTemplate:Clone()
            
            playerDot.Position = UDim2.new(0.5, 0, 0.5, 0)
            playerDot.Parent = radarBG
        end
    end
end


image

I’m pretty sure it’s because you’re looping through all the players and not everything in the workspace. I’m assuming your model in which you’re trying to obtain the HumanoidRootPart from is not a players. So since your script is looping through the player and getting the HumanoidRootPart from there, it won’t pick up HumanoidRootParts from NPCs. So instead you should loop through workspace and get check if anything has a HumanoidRootPart since your NPC and all the players characters would be their