function removeGUIPlayers()local r=gui.Frame.Players:GetChildren()for H=1,#r,1 do r[H]:remove()end end function incrementZIndex()zIndex=zIndex+1 if zIndex>10000 then zIndex=2 end end function createPlayerGUINode(r,H)local o=Instance.new("\073\109\097\103\101\076\097\098\101\108")o.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\048"o.BackgroundTransparency=1 o.BorderSizePixel=0 o.Size=UDim2.new(0,22.5,0,40.5)o.Position=UDim2.new(0,r.x,0,r.y)o.Parent=gui.Frame.Players o.ZIndex=zIndex incrementZIndex()local S=Instance.new("\084\101\120\116\076\097\098\101\108")S.BackgroundTransparency=1 S.BorderSizePixel=1 S.Text=tostring(H)S.Size=UDim2.new(0,150,0,25)S.Parent=o S.Position=UDim2.new(0,-65,0,0)S.TextColor3=Color3.new(0,0,0)S.ZIndex=zIndex incrementZIndex()end function updateGUI()removeGUIPlayers()local r=game.Players:GetChildren()for H=1,#r,1 do local o=r[H].Character:FindFirstChild("\084\111\114\115\111")if o~=nil then local r=Vector3.new(torso.Position.x-o.Position.x,0,torso.Position.z-o.Position.z)if r.magnitude<range and o.Parent.Name~=torso.Parent.Name then r=Vector2.new((r.x+range)*.5,(r.z+range)*.5)local H=Tool.Angle.Value local S=math.abs(H.x)+math.abs(H.z)local d=H.x/S local R=H.z/S local h=math.atan2(1,0)-math.atan2(R,d)local U=Vector2.new(((r.x-radarCenter.x)*math.cos(h)-(r.y-radarCenter.y)*math.sin(h))+radarCenter.x,((r.x-radarCenter.x)*math.sin(h)+(r.y-radarCenter.y)*math.cos(h))+radarCenter.y)createPlayerGUINode(U,o.Parent)elseif o.Parent.Name==torso.Parent.Name then createPlayerGUINode(radarCenter,o.Parent)end end end end while true do if guiEnabled then updateGUI()end wait()end
-- when activated, either bring gui up or down, depending on current state

function removeGUIPlayers()
	local guiPlayers = gui.Frame.Players:GetChildren()
	for i = 1, #guiPlayers do
		guiPlayers[i]:remove()
	end
end

function incrementZIndex()
	zIndex = zIndex + 1
	if zIndex > 10000 then
		zIndex = 2
	end
end

function createPlayerGUINode(pos, playerText)
	local playerIcon = Instance.new("ImageLabel")
	playerIcon.Image = "http://www.roblox.com/asset/?id=0"
	playerIcon.BackgroundTransparency = 1
	playerIcon.BorderSizePixel = 0
	playerIcon.Size = UDim2.new(0, 22.5, 0, 40.5)
	playerIcon.Position = UDim2.new(0, pos.x, 0, pos.y)
	playerIcon.Parent = gui.Frame.Players
	playerIcon.ZIndex = zIndex
	incrementZIndex()

	local playerName = Instance.new("TextLabel")
	playerName.BackgroundTransparency = 1
	playerName.BorderSizePixel = 1

	playerName.Text = tostring(playerText)
	playerName.Size = UDim2.new(0, 150, 0, 25)
	playerName.Parent = playerIcon
	playerName.Position = UDim2.new(0, -65, 0, 0)
	playerName.TextColor3 = Color3.new(0, 0, 0)
	playerName.ZIndex = zIndex
	incrementZIndex()
end

function updateGUI()
	removeGUIPlayers()

	local players = game.Players:GetChildren()

	for i = 1, #players do
		local playerTorso = players[i].Character:FindFirstChild("Torso")

		if playerTorso ~= nil then
			local posDiff =
				Vector3.new(torso.Position.x - playerTorso.Position.x, 0, torso.Position.z - playerTorso.Position.z)

			if posDiff.magnitude < range and playerTorso.Parent.Name ~= torso.Parent.Name then
				-- translate coordinates to radar coordinates
				posDiff = Vector2.new((posDiff.x + range) * 0.5, (posDiff.z + range) * 0.5)

				local rotationVector = Tool.Angle.Value
				local denom = math.abs(rotationVector.x) + math.abs(rotationVector.z)

				local xDirect = (rotationVector.x / denom)
				local zDirect = (rotationVector.z / denom)

				local angle = math.atan2(1, 0) - math.atan2(zDirect, xDirect)

				local point = Vector2.new(
					((posDiff.x - radarCenter.x) * math.cos(angle))
						- ((posDiff.y - radarCenter.y) * math.sin(angle))
						+ radarCenter.x,
					((posDiff.x - radarCenter.x) * math.sin(angle))
						+ ((posDiff.y - radarCenter.y) * math.cos(angle))
						+ radarCenter.y
				)

				createPlayerGUINode(point, playerTorso.Parent)
			elseif playerTorso.Parent.Name == torso.Parent.Name then
				createPlayerGUINode(radarCenter, playerTorso.Parent)
			end
		end
	end
end

while true do
	if guiEnabled then
		updateGUI()
	end
	wait()
end
