#RDR lock

1 messages · Page 1 of 1 (latest)

sudden goblet
#

for somereason lock.Value wont become the seat of closest dot

#

local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
-- CONFIG
local ownSeat = script.RADAR.SurfaceGui.Seat.Value
local dotTemplate = script.RADAR.SurfaceGui.Blip_template -- your blip UI element
local radarRange = 15000 -- studs covered by radar
local radarFrame = script.RADAR.SurfaceGui.RDR_screen
local radarCenter = Vector2.new(0.5, 0.9)

local cursor = script.RADAR.SurfaceGui.RDR_screen.Cursor
local moveSpeed = 0.5 -- Adjust for faster/slower movement
local movingDirection = Vector2.new(0, 0)
local moving = false

local lock = script.Lock -- ObjectValue that holds locked target
local lockDistanceThreshold = 0.4 -- how close the cursor must be (tweak as needed)

-- DATA
local targets = {}
local blipSeatMap = {}

-- Function to collect valid seats (VehicleSeats/Seats above 75 studs)
function Radar.updateTargets()
    targets = {}  -- Clear the list
    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

-- Updates radar dots```
#
    -- Clear previous dots and mapping
    for _, child in ipairs(radarFrame:GetChildren()) do
        if child.Name == "Contact" then
            child:Destroy()
        end
    end
    blipSeatMap = {}

    local ownPos = ownSeat.Position
    local ownHeading = ownSeat.Orientation.Y

    for _, target in ipairs(targets) do
        local relative = target.Position - ownPos
        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)

        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

            -- ✅ Store seat reference in our Lua table
            blipSeatMap[dot] = target
        end
    end
end




-- Internal loop for smooth continuous movement
local function moveCursor()
    while moving do
        cursor.Position = cursor.Position + UDim2.new(
            movingDirection.X * moveSpeed / 100, 0,
            movingDirection.Y * moveSpeed / 100, 0
        )
        wait(RunService.Heartbeat)
    end
end```
#
local function startMove(direction)
    if moving then return end
    moving = true
    movingDirection = direction
    task.spawn(moveCursor)
end

-- Public functions (same names as before)
function Radar.Stop()
    moving = false
end

function Radar.MoveUp()
    Radar.Stop()
    startMove(Vector2.new(0, -1))
end

function Radar.MoveDown()
    Radar.Stop()
    startMove(Vector2.new(0, 1))
end

function Radar.MoveLeft()
    Radar.Stop()
    startMove(Vector2.new(-1, 0))
end

function Radar.MoveRight()
    Radar.Stop()
    startMove(Vector2.new(1, 0))
end```
#
    local radarSize = radarFrame.AbsoluteSize
    local cursorPos = Vector2.new(
        cursor.Position.X.Scale * radarSize.X + cursor.Position.X.Offset,
        cursor.Position.Y.Scale * radarSize.Y + cursor.Position.Y.Offset
    )

    local closestDot, closestDist

    for _, blip in ipairs(radarFrame:GetChildren()) do
        if blip.Name == "Contact" then
            local blipPos = Vector2.new(
                blip.Position.X.Scale * radarSize.X + blip.Position.X.Offset,
                blip.Position.Y.Scale * radarSize.Y + blip.Position.Y.Offset
            )
            local dist = (blipPos - cursorPos).Magnitude

            if dist < lockDistanceThreshold and (not closestDist or dist < closestDist) then
                closestDot = blip
                closestDist = dist
            end
        end
    end

    if closestDot then
        local seat = blipSeatMap[closestDot]
        if seat and seat.Parent then
            lock.Value = seat
            print("[RADAR] ✅ Locked onto:", seat:GetFullName())

            -- ✅ Show "Locked" children
            for _, child in ipairs(closestDot:GetChildren()) do
                if child.Name == "Locked" then
                    child.Visible = true
                end
            end
        end
    else
        print("[RADAR] ❌ No contact near cursor to lock.")
    end
end

function Radar.UnlockTarget()
    if lock.Value then
        print("[RADAR] 🔓 Unlocked target:", lock.Value:GetFullName())
    end

    -- ✅ Hide all "Locked" indicators from all blips
    for _, blip in ipairs(radarFrame:GetChildren()) do
        if blip.Name == "Contact" then
            for _, child in ipairs(blip:GetChildren()) do
                if child.Name == "Locked" then
                    child.Visible = false
                end
            end
        end
    end

    lock.Value = nil
end```

return Radar
next estuary
#

holy chatgpt

sudden goblet