function removeGUIPlayers()local M=gui.Frame.Players:GetChildren()for c=1,#M,1 do M[c]:remove()end end function incrementZIndex()zIndex=zIndex+1 if zIndex>10000 then zIndex=2 end end function createPlayerGUINode(M,c)local Z=Instance.new("\073\109\097\103\101\076\097\098\101\108")Z.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\050\056\054\050\053\053\053\050"Z.BackgroundTransparency=1 Z.BorderSizePixel=0 Z.Size=UDim2.new(0,22.5,0,40.5)Z.Position=UDim2.new(0,M.x,0,M.y)Z.Parent=gui.Frame.Players Z.ZIndex=zIndex incrementZIndex()local N=Instance.new("\084\101\120\116\076\097\098\101\108")N.BackgroundTransparency=1 N.BorderSizePixel=1 N.Text=tostring(c)N.Size=UDim2.new(0,150,0,25)N.Parent=Z N.Position=UDim2.new(0,-65,0,0)N.TextColor3=Color3.new(1,0,.4)N.ZIndex=zIndex incrementZIndex()end function updateGUI()removeGUIPlayers()local M=game.Players:GetChildren()for c=1,#M,1 do local Z=M[c].Character:FindFirstChild("\084\111\114\115\111")if Z~=nil then local M=Vector3.new(torso.Position.x-Z.Position.x,0,torso.Position.z-Z.Position.z)if M.magnitude<range and Z.Parent.Name~=torso.Parent.Name then M=Vector2.new((M.x+range)*.5,(M.z+range)*.5)local c=Tool.Angle.Value local N=math.abs(c.x)+math.abs(c.z)local z=c.x/N local C=c.z/N local O=math.atan2(1,0)-math.atan2(C,z)local t=Vector2.new(((M.x-radarCenter.x)*math.cos(O)-(M.y-radarCenter.y)*math.sin(O))+radarCenter.x,((M.x-radarCenter.x)*math.sin(O)+(M.y-radarCenter.y)*math.cos(O))+radarCenter.y)createPlayerGUINode(t,Z.Parent)elseif Z.Parent.Name==torso.Parent.Name then createPlayerGUINode(radarCenter,Z.Parent)end end end end while true do if guiEnabled then updateGUI()end wait()end



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=28625552"
	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(1,0,0.4)
	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



