Help me make a radar like the one i will put in the image
This is my current radar model
exapmle radar.rbxm (19.0 KB)
It sorta distorts itself in a circle around the radar too (look to the left image around the top where you can see the distortion caused by the beams that reflect back
And then base velocity
images by johnsontv by tw
also im not worried about the map
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local radarPart = script.Parent
local iconTemplateSource = game:GetService("ServerStorage"):WaitForChild("Player") -- For player icons
local textsContainer = radarPart:FindFirstChild("Texts")
local dopplerRadarModel = workspace:FindFirstChild("DopplerRadar")
local stormScanIconTemplate = radarPart:FindFirstChild("Scan") -- Template for storm scan icons
-- Constants
local RADAR_UPDATE_INTERVAL = 5
local RADAR_SCALE_DIVISOR = 30
local MAX_SCAN_DISTANCE = 50000 -- Max distance in studs for storm scans to be visible
local SCANNER_ARM_ROTATION_INCREMENT = 15 -- Degrees per update interval for the scanner arm
-- Variables for the rotating scanner arm
local rotatingScannerArmInstance = nil
local currentScannerAngle = 0
-- Validate essential components
if not iconTemplateSource then
warn("RadarScript Error: Player icon template 'Player' not found in ServerStorage.")
-- Decide if script should stop; for now, it might continue for storms if stormScanIconTemplate exists
end
if not textsContainer then
warn("RadarScript Error: GUI container 'Texts' not found as a child of " .. radarPart:GetFullName())
return
end
if not dopplerRadarModel then
warn("RadarScript Error: 'DopplerRadar' model not found in Workspace.")
return
end
if not stormScanIconTemplate then
warn("RadarScript Error: Storm scan icon template 'Scan' not found as a child of " .. radarPart:GetFullName())
-- Script can continue for player icons if iconTemplateSource exists
end
-- Setup the rotating scanner arm if the template and container exist
local function updateRadarDisplay()
-- Clear previous icons from textsContainer
for _, existingIcon in textsContainer:GetChildren() do
if iconTemplateSource and existingIcon.Name == iconTemplateSource.Name then
existingIcon:Destroy()
end
if stormScanIconTemplate and existingIcon.Name == stormScanIconTemplate.Name then -- This clears pings cloned from stormScanIconTemplate
existingIcon:Destroy()
end
end
-- Rotate the scanner arm
if rotatingScannerArmInstance then
currentScannerAngle = (currentScannerAngle + SCANNER_ARM_ROTATION_INCREMENT) % 360
rotatingScannerArmInstance.Rotation = currentScannerAngle
end
local radcentPo
if dopplerRadarModel and dopplerRadarModel.PrimaryPart then
radcentPo = dopplerRadarModel.PrimaryPart.Position
else
warn("RadarScript Error: DopplerRadar PrimaryPart not found for position calculation.")
return -- Can't proceed without radar center
end
-- Process Storms
if stormScanIconTemplate then -- Still use the original template for cloning pings
local stormRelatedFolder = workspace:FindFirstChild("StormRelated")
if not stormRelatedFolder then
print("RadarScript: StormRelated folder not found in workspace.")
-- Return or handle missing folder; pings won't update
-- For now, let it proceed to player updates
else
local stormsFolder = stormRelatedFolder:FindFirstChild("Storms")
if stormsFolder then
local storms = stormsFolder:GetChildren()
print("RadarScript: Found " .. #storms .. " children in Storms folder.")
for _, stormInstance in storms do
print("RadarScript: Processing stormInstance: " .. stormInstance.Name)
local scanFolder = stormInstance:FindFirstChild("Scan")
if scanFolder then
print("RadarScript: Found 'Scan' folder in " .. stormInstance.Name)
for _, scanObject in scanFolder:GetChildren() do
print("RadarScript: Processing scanObject: " .. scanObject.Name .. " of class " .. scanObject.ClassName)
if scanObject:IsA("BasePart") then
local distance = (scanObject.Position - radcentPo).Magnitude
print("RadarScript: Distance to " .. scanObject.Name .. ": " .. distance)
if distance <= MAX_SCAN_DISTANCE then
print("RadarScript: scanObject " .. scanObject.Name .. " is within MAX_SCAN_DISTANCE. Cloning stormScanIconTemplate.")
local scanIcon = stormScanIconTemplate:Clone() -- Clone the original template for the ping
scanIcon.Name = stormScanIconTemplate.Name
scanIcon.Parent = textsContainer
scanIcon.Visible = true
print("RadarScript: Cloned and parented scanIcon: " .. scanIcon:GetFullName())
local relX = scanObject.Position.X - radcentPo.X
local relZ = scanObject.Position.Z - radcentPo.Z
scanIcon.Position = UDim2.new(0.5, relX / RADAR_SCALE_DIVISOR, 0.5, relZ / RADAR_SCALE_DIVISOR)
print("RadarScript: Positioned scanIcon at " .. tostring(scanIcon.Position))
else
print("RadarScript: scanObject " .. scanObject.Name .. " is beyond MAX_SCAN_DISTANCE. Not showing scan.")
end
else
print("RadarScript: scanObject " .. scanObject.Name .. " is not a BasePart.")
end
end
else
print("RadarScript: 'Scan' folder NOT found in " .. stormInstance.Name)
end
end
else
print("RadarScript: Storms folder NOT found in StormRelated.")
end
end
else
print("RadarScript: stormScanIconTemplate is nil. Skipping storm processing.")
end
-- Process Players
if iconTemplateSource then
local radarCenterPosition = radcentPo -- Use the same radar center position
for _, playerInstance in Players:GetPlayers() do
local playerCharacter = playerInstance.Character
if playerCharacter then
local rootPart = playerCharacter:FindFirstChild("HumanoidRootPart")
if rootPart then
local newIcon = iconTemplateSource:Clone()
newIcon.Name = iconTemplateSource.Name
newIcon.Parent = textsContainer
newIcon.Visible = true
local relativeX = rootPart.Position.X - radarCenterPosition.X
local relativeZ = rootPart.Position.Z - radarCenterPosition.Z
newIcon.Position = UDim2.new(0.5, -relativeX / RADAR_SCALE_DIVISOR, 0.5, -relativeZ / RADAR_SCALE_DIVISOR)
local arrowElement = newIcon:FindFirstChild("Arrow")
if arrowElement then
arrowElement.Rotation = -rootPart.Orientation.Y + 180
if arrowElement:IsA("ImageLabel") or arrowElement:IsA("ImageButton") then
arrowElement.ImageColor3 = playerInstance.TeamColor.Color
end
end
local successText, errText = pcall(function()
if newIcon:IsA("TextLabel") or newIcon:IsA("TextButton") then
newIcon.Text = playerInstance.Name
newIcon.TextColor3 = playerInstance.TeamColor.Color
end
end)
if not successText then
warn("RadarScript Warning: Could not set Text/TextColor3 on newIcon: " .. errText)
end
end
end
end
else
print("RadarScript: iconTemplateSource is nil. Skipping player processing.")
end
end
-- Main loop
while task.wait(RADAR_UPDATE_INTERVAL) do
updateRadarDisplay()
end
Try this out
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ServerStorage = game:GetService("ServerStorage")
local radarPart = script.Parent
local iconTemplateSource = ServerStorage:FindFirstChild("Player") -- For player icons
local textsContainer = radarPart:FindFirstChild("Texts")
local dopplerRadarModel = workspace:FindFirstChild("DopplerRadar")
local stormScanIconTemplate = radarPart:FindFirstChild("Scan") -- Template for storm scan icons
-- Constants
local RADAR_UPDATE_INTERVAL = 5
local RADAR_SCALE_DIVISOR = 30
local MAX_SCAN_DISTANCE = 50000 -- Max distance in studs for storm scans to be visible
local SCANNER_ARM_ROTATION_INCREMENT = 15 -- Degrees per update interval for the scanner arm
-- Variables for the rotating scanner arm
local rotatingScannerArmInstance = nil
local currentScannerAngle = 0
-- Try to find a scanner arm as a child of radarPart (optional)
for _, child in radarPart:GetChildren() do
if child:IsA("GuiObject") and child.Name == "ScannerArm" then
rotatingScannerArmInstance = child
break
end
end
-- Helper function to get a BasePart from a model (since PrimaryPart is not guaranteed)
local function getAnyBasePart(model)
for _, obj in model:GetChildren() do
if obj:IsA("BasePart") then
return obj
end
end
return nil
end
-- Validate essential components
if not iconTemplateSource then
warn("RadarScript Error: Player icon template 'Player' not found in ServerStorage.")
-- Decide if script should stop; for now, it might continue for storms if stormScanIconTemplate exists
end
if not textsContainer then
warn("RadarScript Error: GUI container 'Texts' not found as a child of " .. radarPart:GetFullName())
return
end
if not dopplerRadarModel then
warn("RadarScript Error: 'DopplerRadar' model not found in Workspace.")
return
end
if not stormScanIconTemplate then
warn("RadarScript Error: Storm scan icon template 'Scan' not found as a child of " .. radarPart:GetFullName())
-- Script can continue for player icons if iconTemplateSource exists
end
local function updateRadarDisplay()
-- Clear previous icons from textsContainer
for _, existingIcon in textsContainer:GetChildren() do
if iconTemplateSource and existingIcon.Name == iconTemplateSource.Name then
existingIcon:Destroy()
end
if stormScanIconTemplate and existingIcon.Name == stormScanIconTemplate.Name then
existingIcon:Destroy()
end
end
-- Rotate the scanner arm
if rotatingScannerArmInstance then
currentScannerAngle = (currentScannerAngle + SCANNER_ARM_ROTATION_INCREMENT) % 360
rotatingScannerArmInstance.Rotation = currentScannerAngle
end
local radcentPo
local radarBasePart = getAnyBasePart(dopplerRadarModel)
if radarBasePart then
radcentPo = radarBasePart.Position
else
warn("RadarScript Error: DopplerRadar has no BasePart for position calculation.")
return -- Can't proceed without radar center
end
-- Process Storms
if stormScanIconTemplate then
local stormRelatedFolder = workspace:FindFirstChild("StormRelated")
if not stormRelatedFolder then
print("RadarScript: StormRelated folder not found in workspace.")
else
local stormsFolder = stormRelatedFolder:FindFirstChild("Storms")
if stormsFolder then
local storms = stormsFolder:GetChildren()
print("RadarScript: Found " .. #storms .. " children in Storms folder.")
for _, stormInstance in storms do
print("RadarScript: Processing stormInstance: " .. stormInstance.Name)
local scanFolder = stormInstance:FindFirstChild("Scan")
if scanFolder then
print("RadarScript: Found 'Scan' folder in " .. stormInstance.Name)
for _, scanObject in scanFolder:GetChildren() do
print("RadarScript: Processing scanObject: " .. scanObject.Name .. " of class " .. scanObject.ClassName)
if scanObject:IsA("BasePart") then
local distance = (scanObject.Position - radcentPo).Magnitude
print("RadarScript: Distance to " .. scanObject.Name .. ": " .. distance)
if distance <= MAX_SCAN_DISTANCE then
print("RadarScript: scanObject " .. scanObject.Name .. " is within MAX_SCAN_DISTANCE. Cloning stormScanIconTemplate.")
local scanIcon = stormScanIconTemplate:Clone()
scanIcon.Name = stormScanIconTemplate.Name
scanIcon.Parent = textsContainer
scanIcon.Visible = true
print("RadarScript: Cloned and parented scanIcon: " .. scanIcon:GetFullName())
local relX = scanObject.Position.X - radcentPo.X
local relZ = scanObject.Position.Z - radcentPo.Z
scanIcon.Position = UDim2.new(0.5, relX / RADAR_SCALE_DIVISOR, 0.5, relZ / RADAR_SCALE_DIVISOR)
print("RadarScript: Positioned scanIcon at " .. tostring(scanIcon.Position))
else
print("RadarScript: scanObject " .. scanObject.Name .. " is beyond MAX_SCAN_DISTANCE. Not showing scan.")
end
else
print("RadarScript: scanObject " .. scanObject.Name .. " is not a BasePart.")
end
end
else
print("RadarScript: 'Scan' folder NOT found in " .. stormInstance.Name)
end
end
else
print("RadarScript: Storms folder NOT found in StormRelated.")
end
end
else
print("RadarScript: stormScanIconTemplate is nil. Skipping storm processing.")
end
-- Process Players
if iconTemplateSource then
local radarCenterPosition = radcentPo
for _, playerInstance in Players:GetPlayers() do
local playerCharacter = playerInstance.Character
if playerCharacter then
local rootPart = playerCharacter:FindFirstChild("HumanoidRootPart")
if rootPart then
local newIcon = iconTemplateSource:Clone()
newIcon.Name = iconTemplateSource.Name
newIcon.Parent = textsContainer
newIcon.Visible = true
local relativeX = rootPart.Position.X - radarCenterPosition.X
local relativeZ = rootPart.Position.Z - radarCenterPosition.Z
newIcon.Position = UDim2.new(0.5, -relativeX / RADAR_SCALE_DIVISOR, 0.5, -relativeZ / RADAR_SCALE_DIVISOR)
local arrowElement = newIcon:FindFirstChild("Arrow")
if arrowElement then
arrowElement.Rotation = -rootPart.Orientation.Y + 180
if arrowElement:IsA("ImageLabel") or arrowElement:IsA("ImageButton") then
arrowElement.ImageColor3 = playerInstance.TeamColor.Color
end
end
local successText, errText = pcall(function()
if newIcon:IsA("TextLabel") or newIcon:IsA("TextButton") then
newIcon.Text = playerInstance.Name
newIcon.TextColor3 = playerInstance.TeamColor.Color
end
end)
if not successText then
warn("RadarScript Warning: Could not set Text/TextColor3 on newIcon: " .. errText)
end
end
end
end
else
print("RadarScript: iconTemplateSource is nil. Skipping player processing.")
end
end
-- Main loop
while task.wait(RADAR_UPDATE_INTERVAL) do
updateRadarDisplay()
end