hello, im having a bit of trouble.
im creating a Fighter plane and part of the fighter plane is that it has a radar that can lock targets, so i went ahead and created a script (will come sceperately because too large) that displays the targets. now as a way of locking those targets i want to have a cursor that i can steer over the target i want to lock, and eventualy lock it (but first the cursor steering part)
#Radar cursor
1 messages · Page 1 of 1 (latest)
-- CONFIG
local ownSeat = script.Seat.Value
local dotTemplate = script.Blip_template -- your blip UI element
local radarRange = 15000 -- studs covered by radar
local radarFrame = script.Parent
local radarCenter = Vector2.new(0.5, 0.9)
-- DATA
local targets = {}
-- Collects targets in workspace
local function updateTargets()
targets = {}
for _, seat in ipairs(workspace:GetDescendants()) do
if (seat:IsA("VehicleSeat") or seat:IsA("Seat")) and seat.Position.Y > 75 then
table.insert(targets, seat)
end
end
end```
local function updateRadarDots()
-- Clear previous dots
for _, child in ipairs(radarFrame:GetChildren()) do
if child.Name == "Contact" then
child:Destroy()
end
end
-- Update ownship position & heading
local ownPos = ownSeat.Position
local ownHeading = ownSeat.Orientation.Y
for _, target in ipairs(targets) do
local relative = target.Position - ownPos
-- Rotate by own heading (heading-up)
local headingRad = math.rad(ownHeading)
local relX = relative.X
local relZ = relative.Z
local rotatedX = relX * math.cos(headingRad) - relZ * math.sin(headingRad)
local rotatedY = relX * math.sin(headingRad) + relZ * math.cos(headingRad)
-- ✅ Scale and flip Y correctly so forward = up
local scaledX = radarCenter.X + (rotatedX / radarRange) * 0.5
local scaledY = radarCenter.Y + (rotatedY / radarRange) * 0.5
if scaledX >= 0 and scaledX <= 1 and scaledY >= 0 and scaledY <= 1 then
local dot = dotTemplate:Clone()
dot.Name = "Contact"
dot.Position = UDim2.new(scaledX, 0, scaledY, 0)
dot.Parent = radarFrame
dot.Visible = true
end
end
end
-- Update every frame
RunService.Heartbeat:Connect(function()
updateTargets()
updateRadarDots()
end)
holy chatgpt
the emoji 💔
yeah i know, but it works
wait if it works whats the trouble
well
this is only part one of the script
i dont know how i need to go about part 2
i just need some guidance
cause its.... complicated
like if you do one thing wrong, it breaks the system
like
the system of the plane
and
another problem
it doesnt work when i put it in a module script
and i kinda need it to
the problem is we help you fix 1 and another will appear again cause you have no idea what ur doin
i know what im doing