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