I want a radar that shows players in the game’s location on a SurfaceGUI and I found a video on YouTube that does that but it’s a ScreenGUI. Here’s the script that goes into the ScreenGUI normally. The workspace.radar used to be script.Parent but I changed it to be compatible with a SurfaceGUI. The following code is on a LocalScript located in StarerPlayerScripts. Nothing but a black screen appears on the radar. How can I make it work?
local radarBG = workspace.radar:WaitForChild("Background")
local playerDotTemplate = game.ReplicatedStorage:WaitForChild("PlayerDot")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
game:GetService("RunService").RenderStepped:Connect(function()
radarBG:ClearAllChildren()
local uiAspectRatioConstraint = Instance.new("UIAspectRatioConstraint", radarBG)
for i, otherPlayer in pairs(game.Players:GetPlayers()) do
local otherChar = otherPlayer.Character
if otherPlayer ~= plr then
if otherChar and otherChar:FindFirstChild("HumanoidRootPart") and char:FindFirstChild("HumanoidRootPart") then
local playerDot = playerDotTemplate:Clone()
local offset = otherChar.HumanoidRootPart.Position - char.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)