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



