local X=workspace.CurrentCamera local G={MinhaVisao=1;RosaDosVentos=1;FoeBlip=1,FriendBlip=1}local E={UIGridLayout=1}Character.Humanoid.Died:Connect(function()script.Parent.Enabled=false end);(game:GetService("\082\117\110\083\101\114\118\105\099\101")).RenderStepped:connect(function()local m=(Vector2.new(X.Focus.x,X.Focus.z)-Vector2.new(X.CoordinateFrame.x,X.CoordinateFrame.z)).unit local C=math.atan2(m.y,m.x)*(-180/math.pi)-90 if Saude.FireTeam.SquadName.Value~=""then MinhasVisao.ImageColor3=Saude.FireTeam.SquadColor.Value else MinhasVisao.ImageColor3=Color3.fromRGB(255,255,255)end local a=Vector3.new(X.CoordinateFrame.x,0,X.CoordinateFrame.z)local h=Vector3.new(X.Focus.x,0,X.Focus.z)local B=CFrame.new(h,a)script.Parent.Frame.RosaDosVentos.Rotation=C local l=game.Players:GetChildren()if Saude.FireTeam.SquadName.Value~=""and Player then script.Parent.Squad.Visible=true script.Parent.Squad.Esquadrao.Text=Saude.FireTeam.SquadName.Value else script.Parent.Squad.Visible=false end local K=script.Parent.Squad.Membros:GetChildren()for X=1,#K,1 do if not E[K[X].Name]then K[X]:Destroy()end end for X=1,#l,1 do if l[X]~=Player and(l[X].Character and(Player and Player.Character))then local G=script.Parent.Squad.Membros:FindFirstChild(l[X].Name)if not G then if l[X].TeamColor==Player.TeamColor and(l[X].Character.Saude.FireTeam.SquadName.Value==Player.Character.Saude.FireTeam.SquadName.Value and Player.Character.Saude.FireTeam.SquadName.Value~="")then G=script.Parent.Squad.Exemplo:Clone()G.Visible=true G.Text=l[X].Name G.Name=l[X].Name G.Parent=script.Parent.Squad.Membros end end end end local I=RadarFrame:GetChildren()for X=1,#I,1 do if not G[I[X].Name]then I[X]:Destroy()end end for X=1,#l,1 do if l[X]~=Player and(l[X].Character and(Player and Player.Character))then local G=RadarFrame:FindFirstChild(l[X].Name)if not G then if l[X].TeamColor==Player.TeamColor then G=FriendBlip:Clone()else G=FoeBlip:Clone()end G.Visible=false G.Name=l[X].Name G.Parent=RadarFrame end if l[X].Character:FindFirstChild("\072\117\109\097\110\111\105\100")and l[X].Character:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")then local E=CFrame.new(l[X].Character.HumanoidRootPart.Position.X,0,l[X].Character.HumanoidRootPart.Position.Z)local m=B:inverse()*E local a=m.p.Magnitude/RANGE if a<.9 then local E=.5-(m.x/RANGE)/2 local a=.5-(m.z/RANGE)/2 G.Position=UDim2.new(E,0,a,0)G.Rotation=-l[X].Character.HumanoidRootPart.Orientation.Y+C if l[X].TeamColor==Player.TeamColor then if l[X].Character.Saude.FireTeam.SquadName.Value~=""then G.ImageColor3=l[X].Character.Saude.FireTeam.SquadColor.Value else G.ImageColor3=FriendBlip.ImageColor3 end else G.ImageColor3=FoeBlip.ImageColor3 end G.Visible=true else G.Visible=false end else G.Visible=false end end end end)


local Camera = workspace.CurrentCamera

local SaveList = {MinhaVisao = 1, RosaDosVentos = 1, FoeBlip = 1, FriendBlip = 1}
local SquadSave = {UIGridLayout = 1}


Character.Humanoid.Died:Connect(function()
	script.Parent.Enabled = false
end)

game:GetService("RunService").RenderStepped:connect(function()

	local Direction = (Vector2.new(Camera.Focus.x,Camera.Focus.z)-Vector2.new(Camera.CoordinateFrame.x,Camera.CoordinateFrame.z)).unit
	local theta = (math.atan2(Direction.y,Direction.x))*(-180/math.pi) - 90	

	if Saude.FireTeam.SquadName.Value ~= "" then
		MinhasVisao.ImageColor3 = Saude.FireTeam.SquadColor.Value
	else
		MinhasVisao.ImageColor3 = Color3.fromRGB(255,255,255)
	end
	
	local frame = Vector3.new(Camera.CoordinateFrame.x, 0, Camera.CoordinateFrame.z)
	local focus = Vector3.new(Camera.Focus.x, 0, Camera.Focus.z)
	local frame = CFrame.new(focus, frame)

	script.Parent.Frame.RosaDosVentos.Rotation = theta
	local players = game.Players:GetChildren()

	if Saude.FireTeam.SquadName.Value ~= "" and Player then
		script.Parent.Squad.Visible = true
		script.Parent.Squad.Esquadrao.Text = Saude.FireTeam.SquadName.Value
	else
		script.Parent.Squad.Visible = false
	end

	local Nomes = script.Parent.Squad.Membros:GetChildren()
	for i = 1, #Nomes do
		if not SquadSave[Nomes[i].Name] then
			Nomes[i]:Destroy()
		end
	end

	for i = 1, #players do
		if players[i] ~= Player and players[i].Character and Player and Player.Character then
			local unit = script.Parent.Squad.Membros:FindFirstChild(players[i].Name)
			if not unit then
				if players[i].TeamColor == Player.TeamColor and players[i].Character.Saude.FireTeam.SquadName.Value == Player.Character.Saude.FireTeam.SquadName.Value and Player.Character.Saude.FireTeam.SquadName.Value ~= "" then
					unit = script.Parent.Squad.Exemplo:Clone()
					unit.Visible = true
					unit.Text = players[i].Name
					unit.Name = players[i].Name
					unit.Parent = script.Parent.Squad.Membros
				end
			end
		end
	end


	local labels = RadarFrame:GetChildren()
	for i = 1, #labels do
		if not SaveList[labels[i].Name] then
			labels[i]:Destroy()
		end
	end

	for i = 1, #players do
		if players[i] ~= Player and players[i].Character and Player and Player.Character then
			local unit = RadarFrame:FindFirstChild(players[i].Name)
			if not unit then
				if players[i].TeamColor == Player.TeamColor then
					unit = FriendBlip:Clone()
				else
					unit = FoeBlip:Clone()
				end
				unit.Visible = false
				unit.Name = players[i].Name
				unit.Parent = RadarFrame
			end


			if players[i].Character:FindFirstChild('Humanoid') and players[i].Character:FindFirstChild('HumanoidRootPart') then

				-- Get the relative position of the players
				local pos = CFrame.new(players[i].Character.HumanoidRootPart.Position.X, 0, players[i].Character.HumanoidRootPart.Position.Z)
				local relativeCFrame = frame:inverse() * pos
				local distanceRatio = relativeCFrame.p.Magnitude/RANGE
				if distanceRatio < 0.9 then
					local xScale = 0.5 - ((relativeCFrame.x/RANGE)/2)
					local yScale = 0.5 - ((relativeCFrame.z/RANGE)/2)
					unit.Position = UDim2.new(xScale, 0, yScale, 0)
					unit.Rotation = -players[i].Character.HumanoidRootPart.Orientation.Y + theta
				
				if players[i].TeamColor == Player.TeamColor then
					if players[i].Character.Saude.FireTeam.SquadName.Value ~= "" then
						unit.ImageColor3 = players[i].Character.Saude.FireTeam.SquadColor.Value
					else
						unit.ImageColor3 = FriendBlip.ImageColor3
					end
				else
					unit.ImageColor3 = FoeBlip.ImageColor3
				end
					unit.Visible = true
					
				else
					unit.Visible = false
				end
			else
				unit.Visible = false
			end
		end
	end
end)
