Skip to content
The Chat Archive
o1-mini-2024-09-12· OpenAI WildChat-4.8M (AI2)

fix initial scan failed failed to find enemy position failed to find enemy position.…

  1. User

    fix initial scan failed failed to find enemy position failed to find enemy position. retrying in 1 second starting intial unkown scan for enemy x position Error: first scan failed --[[ Final Lua Script for Cheat Engine Purpose: Memory Scanning and Manipulation for Enemy and Player Aim Positions Author: [Your Name] Date: [Today's Date] --]]

    -- ==================== Configuration ====================

    -- Define scan options if not already defined -- These constants are typically predefined in Cheat Engine, but defining them ensures compatibility if soUnknownInitialValue == nil then soUnknownInitialValue = 0 end -- "Unknown initial value" scan option if soUnknownValueChanged == nil then soUnknownValueChanged = 6 end -- "Unknown value changed" scan option

    -- Define value types -- Adjust based on how the game represents position data -- Common types: vtFloat = 0, vtDouble = 1, vtByte = 2, vtWord = 3, vtDword = 4 if vtFloat == nil then vtFloat = 0 end if vtDword == nil then vtDword = 4 end

    -- Select the value type you need (commonly vtFloat for positions) local VALUE_TYPE = vtFloat

    -- ==================== Utility Functions ====================

    -- Function to read a 32-bit integer or float from memory function readValue(address, valueType) if valueType == vtDword then local value = readInteger(address) if value == nil then print(string.format("Error: Failed to read integer from address 0x%X", address)) return nil end return tonumber(value) elseif valueType == vtFloat then local value = readFloat(address) if value == nil then print(string.format("Error: Failed to read float from address 0x%X", address)) return nil end return tonumber(value) else print("Error: Unsupported value type.") return nil end end

    -- Function to write a 32-bit integer or float to memory function writeValue(address, value, valueType) local success if valueType == vtDword then success = writeInteger(address, value) elseif valueType == vtFloat then success = writeFloat(address, value) else print("Error: Unsupported value type.") return end

    if not success then
        print(string.format("Error: Failed to write value to address 0x%X", address))
    end
    

    end

    -- Function to perform an initial unknown value scan function initialScanUnknown(scanOption) local memscan = createMemScan() if not memscan then print("Error: Failed to create memscan object.") return false, nil end

    -- Start the initial scan with the correct scan option
    local scanSuccess = memscan.FirstScan(scanOption, VALUE_TYPE, "", 0, 0, "", "", "")
    if not scanSuccess then
        print("Error: FirstScan failed.")
        memscan.destroy()
        return false, nil
    end
    
    local foundlist = memscan.FoundList
    if not foundlist then
        print("Error: FoundList is nil after FirstScan.")
        memscan.destroy()
        return false, nil
    end
    
    -- Initialize the found list
    local initSuccess, initError = pcall(function() foundlist.Initialize() end)
    if not initSuccess then
        print("Error: Failed to initialize FoundList. Details:", initError)
        memscan.destroy()
        return false, nil
    end
    
    -- Check if foundlist is valid
    if not foundlist or foundlist.Count == nil then
        print("Error: FoundList is invalid after initialization.")
        memscan.destroy()
        return false, nil
    end
    
    memscan.destroy()
    
    if foundlist.Count > 0 then
        print(string.format("Initial scan successful. %d results found.", foundlist.Count))
        return true, foundlist
    else
        print("No results found in FoundList after initial scan.")
        return false, nil
    end
    

    end

    -- Function to perform a narrow down unknown value changed scan function narrowDownScanUnknown(foundlist, scanOption) if not foundlist then print("Error: Provided foundlist is nil.") return false, nil end

    local memscan = createMemScan()
    if not memscan then
        print("Error: Failed to create memscan object.")
        return false, nil
    end
    
    -- Begin the narrow down scan with the correct scan option
    local beginSuccess = memscan.BeginScan(foundlist, scanOption, VALUE_TYPE, "", 0, 0, "", "", "")
    if not beginSuccess then
        print("Error: BeginScan failed.")
        memscan.destroy()
        return false, nil
    end
    
    local updateSuccess = memscan.UpdateScan()
    if not updateSuccess then
        print("Error: UpdateScan failed.")
        memscan.destroy()
        return false, nil
    end
    
    local newFoundList = memscan.FoundList
    if not newFoundList then
        print("Error: FoundList is nil after narrow down scan.")
        memscan.destroy()
        return false, nil
    end
    
    -- Initialize the new found list
    local initSuccess, initError = pcall(function() newFoundList.Initialize() end)
    if not initSuccess then
        print("Error: Failed to initialize new FoundList. Details:", initError)
        memscan.destroy()
        return false, nil
    end
    
    memscan.destroy()
    
    if newFoundList.Count > 0 then
        print(string.format("Narrow down scan successful. %d results found.", newFoundList.Count))
        return true, newFoundList
    else
        print("No results found in new FoundList after narrow down scan.")
        return false, nil
    end
    

    end

    -- Function to find a unique address by repeatedly narrowing down the scan function findUniqueAddress(initialScanOption, narrowScanOption, promptMessage) -- Perform initial scan local success, foundlist = initialScanUnknown(initialScanOption) if not success then print("Initial scan failed.") return nil end

    -- Repeat narrowing down until one address is found or no results remain
    while foundlist.Count > 1 do
        print(promptMessage)
        -- Wait for user input to proceed (manual change in game state)
        io.read()
    
        -- Perform narrow down scan
        local successNarrow, newFoundList = narrowDownScanUnknown(foundlist, narrowScanOption)
        if not successNarrow then
            print("Narrow down scan failed.")
            foundlist.destroy()
            return nil
        end
    
        -- Destroy previous found list and update to new one
        foundlist.destroy()
        foundlist = newFoundList
    end
    
    -- Check if exactly one result is found
    if foundlist.Count == 1 then
        local addressList = foundlist.Address
        if addressList and addressList[0] then
            local address = addressList[0]
            foundlist.destroy()
            print(string.format("Unique address found: 0x%X", address))
            return address
        else
            print("Error: Address list is invalid.")
            foundlist.destroy()
            return nil
        end
    else
        print("Failed to uniquely identify the address.")
        foundlist.destroy()
        return nil
    end
    

    end

    -- Function to find the enemy's position function findEnemyPosition() print("Starting initial unknown scan for enemy X position...") local enemyXAddress = findUniqueAddress( soUnknownInitialValue, soUnknownValueChanged, "Change the enemy's position in-game and press Enter..." ) if not enemyXAddress then print("Failed to find enemy position.") return nil, nil, nil, nil end

    print(string.format("Enemy X Address Found: 0x%X", enemyXAddress))
    
    -- Read Y and Z positions based on known offsets
    local enemyYAddress = enemyXAddress + 4  -- Assuming 4 bytes per coordinate
    local enemyZAddress = enemyXAddress + 8
    
    local enemyX = readValue(enemyXAddress, VALUE_TYPE)
    local enemyY = readValue(enemyYAddress, VALUE_TYPE)
    local enemyZ = readValue(enemyZAddress, VALUE_TYPE)
    
    if enemyX == nil or enemyY == nil or enemyZ == nil then
        print("Error: Failed to read one or more enemy position values.")
        return nil, nil, nil, nil
    end
    
    print(string.format("Enemy Position: X=%.2f, Y=%.2f, Z=%.2f", enemyX, enemyY, enemyZ))
    return enemyX, enemyY, enemyZ, enemyXAddress
    

    end

    -- Function to find the player's aim position function findPlayerAimPosition() print("Starting initial unknown scan for player aim X position...") local playerAimXAddress = findUniqueAddress( soUnknownInitialValue, soUnknownValueChanged, "Change the player's aim in-game and press Enter..." ) if not playerAimXAddress then print("Failed to find player aim position.") return nil, nil, nil, nil end

    print(string.format("Player Aim X Address Found: 0x%X", playerAimXAddress))
    
    -- Read Y and Z positions based on known offsets
    local playerAimYAddress = playerAimXAddress + 4  -- Assuming 4 bytes per coordinate
    local playerAimZAddress = playerAimXAddress + 8
    
    local playerAimX = readValue(playerAimXAddress, VALUE_TYPE)
    local playerAimY = readValue(playerAimYAddress, VALUE_TYPE)
    local playerAimZ = readValue(playerAimZAddress, VALUE_TYPE)
    
    if playerAimX == nil or playerAimY == nil or playerAimZ == nil then
        print("Error: Failed to read one or more player aim position values.")
        return nil, nil, nil, nil
    end
    
    print(string.format("Player Aim Position: X=%.2f, Y=%.2f, Z=%.2f", playerAimX, playerAimY, playerAimZ))
    return playerAimX, playerAimY, playerAimZ, playerAimXAddress
    

    end

    -- Function to calculate the aim offset function calculateAimOffset(enemyX, enemyY, enemyZ, playerAimX, playerAimY, playerAimZ) -- Calculate the offset to aim at the enemy's head local offsetX = enemyX - playerAimX local offsetY = enemyY - playerAimY local offsetZ = enemyZ - playerAimZ

    -- Adjust the aim (this is a simple example, you may need to fine-tune the values)
    local newAimX = playerAimX + offsetX
    local newAimY = playerAimY + offsetY
    local newAimZ = playerAimZ + offsetZ
    
    return newAimX, newAimY, newAimZ
    

    end

    -- ==================== Main Loop ====================

    -- Function to safely destroy foundlist function safeDestroy(foundlist) if foundlist and foundlist.destroy then foundlist:destroy() end end

    -- Main loop while true do ::continue:: -- Label moved to the beginning of the loop

    -- Find the enemy's position
    local enemyX, enemyY, enemyZ, enemyXAddress = findEnemyPosition()
    if not enemyX or not enemyY or not enemyZ then
        print("Failed to find enemy position. Retrying in 1 second...")
        sleep(1000) -- Sleep for 1 second
        goto continue
    end
    
    -- Find the player's aim position
    local playerAimX, playerAimY, playerAimZ, playerAimXAddress = findPlayerAimPosition()
    if not playerAimX or not playerAimY or not playerAimZ then
        print("Failed to find player aim position. Retrying in 1 second...")
        sleep(1000) -- Sleep for 1 second
        goto continue
    end
    
    -- Calculate the aim offset
    local newAimX, newAimY, newAimZ = calculateAimOffset(
        enemyX, enemyY, enemyZ,
        playerAimX, playerAimY, playerAimZ
    )
    
    -- Write the new aim position back to memory
    writeValue(playerAimXAddress, newAimX, VALUE_TYPE)
    writeValue(playerAimXAddress + 4, newAimY, VALUE_TYPE)
    writeValue(playerAimXAddress + 8, newAimZ, VALUE_TYPE)
    
    print(string.format("Aim adjusted to X=%.2f, Y=%.2f, Z=%.2f", newAimX, newAimY, newAimZ))
    
    -- Sleep to avoid high CPU usage
    sleep(10) -- Sleep for 10 milliseconds
    

    end

  2. Assistant

    It looks like you're encountering issues with the initial memory scan failing in your Cheat Engine Lua script. Let's walk through potential causes and provide adjustments to help resolve the issue.

    Potential Issues:

    1. Incorrect Usage of FoundList.Initialize():

      • Explanation: In Cheat Engine's Lua API, the FoundList is automatically initialized after a successful scan. Manually calling foundlist.Initialize() may disrupt this process and lead to unexpected behavior.
    2. Assumptions About Memory Layout:

      • Explanation: The script assumes that the enemy's Y and Z positions are located at enemyXAddress + 4 and enemyXAddress + 8, respectively. This might not be accurate depending on the game's memory structure.
    3. Scan Options and Value Types:

      • Explanation: Ensuring that the scan options (soUnknownInitialValue and soUnknownValueChanged) and value types (vtFloat) are correctly set is crucial. If the game uses a different data type for positions (e.g., vtDouble), the scan will fail.
    4. Process Attachment and Permissions:

      • Explanation: Make sure that Cheat Engine is properly attached to the target process and has the necessary permissions to read and write memory.
    5. Error Handling and Debugging:

      • Explanation: Enhancing debug statements can provide more insights into where the scan is failing.

    Recommended Fixes:

    1. Remove foundlist.Initialize() Calls:

      • Reason: As mentioned, FoundList is already initialized after FirstScan and UpdateScan. Manually re-initializing can cause issues.
    2. Verify Memory Offsets:

      • Action: Confirm the correct offsets for the Y and Z coordinates relative to the X coordinate. This often requires inspecting the game's memory manually or using Cheat Engine's built-in tools to find the correct structure.
    3. Enhance Debugging:

      • Action: Add more detailed debug statements to understand where the scan is failing.
    4. Validate Value Types:

      • Action: Ensure that the game uses float for position values. If it uses double or another type, adjust VALUE_TYPE accordingly.
    5. Ensure Proper Process Attachment:

      • Action: Before running the script, make sure Cheat Engine is correctly attached to the target process and that the process is running in a state where positions are actively being updated.

    Revised Lua Script:

    Below is the revised script with the recommended fixes applied:

    --[[ 
        Final Lua Script for Cheat Engine
        Purpose: Memory Scanning and Manipulation for Enemy and Player Aim Positions
        Author: [Your Name]
        Date: [Today's Date]
    --]]
    
    -- ==================== Configuration ====================
    
    -- Define scan options if not already defined
    if soUnknownInitialValue == nil then soUnknownInitialValue = 0 end -- "Unknown initial value" scan option
    if soUnknownValueChanged == nil then soUnknownValueChanged = 6 end -- "Unknown value changed" scan option
    
    -- Define value types
    -- Adjust based on how the game represents position data
    -- Common types: vtFloat = 0, vtDouble = 1, vtByte = 2, vtWord = 3, vtDword = 4
    if vtFloat == nil then vtFloat = 0 end
    if vtDword == nil then vtDword = 4 end
    if vtDouble == nil then vtDouble = 1 end -- Added vtDouble in case it's needed
    
    -- Select the value type you need (commonly vtFloat for positions)
    local VALUE_TYPE = vtFloat
    
    -- ==================== Utility Functions ====================
    
    -- Function to read a 32-bit integer or float from memory
    function readValue(address, valueType)
        if valueType == vtDword then
            local value = readInteger(address)
            if value == nil then
                print(string.format("Error: Failed to read integer from address 0x%X", address))
                return nil
            end
            return tonumber(value)
        elseif valueType == vtFloat then
            local value = readFloat(address)
            if value == nil then
                print(string.format("Error: Failed to read float from address 0x%X", address))
                return nil
            end
            return tonumber(value)
        elseif valueType == vtDouble then
            local value = readDouble(address)
            if value == nil then
                print(string.format("Error: Failed to read double from address 0x%X", address))
                return nil
            end
            return tonumber(value)
        else
            print("Error: Unsupported value type.")
            return nil
        end
    end
    
    -- Function to write a 32-bit integer or float to memory
    function writeValue(address, value, valueType)
        local success
        if valueType == vtDword then
            success = writeInteger(address, value)
        elseif valueType == vtFloat then
            success = writeFloat(address, value)
        elseif valueType == vtDouble then
            success = writeDouble(address, value)
        else
            print("Error: Unsupported value type.")
            return
        end
    
        if not success then
            print(string.format("Error: Failed to write value to address 0x%X", address))
        end
    end
    
    -- Function to perform an initial unknown value scan
    function initialScanUnknown(scanOption)
        local memscan = createMemScan()
        if not memscan then
            print("Error: Failed to create memscan object.")
            return false, nil
        end
    
        -- Start the initial scan with the correct scan option
        local scanSuccess = memscan.FirstScan(scanOption, VALUE_TYPE, "unknown", nil, nil, nil, nil, nil)
        if not scanSuccess then
            print("Error: FirstScan failed.")
            memscan.destroy()
            return false, nil
        end
    
        local foundlist = memscan.FoundList
        if not foundlist then
            print("Error: FoundList is nil after FirstScan.")
            memscan.destroy()
            return false, nil
        end
    
        -- No need to call foundlist.Initialize()
    
        memscan.destroy()
    
        if foundlist.Count > 0 then
            print(string.format("Initial scan successful. %d results found.", foundlist.Count))
            return true, foundlist
        else
            print("No results found in FoundList after initial scan.")
            return false, nil
        end
    end
    
    -- Function to perform a narrow down unknown value changed scan
    function narrowDownScanUnknown(foundlist, scanOption)
        if not foundlist then
            print("Error: Provided foundlist is nil.")
            return false, nil
        end
    
        local memscan = createMemScan()
        if not memscan then
            print("Error: Failed to create memscan object.")
            return false, nil
        end
    
        -- Begin the narrow down scan with the correct scan option
        local beginSuccess = memscan.BeginScan(foundlist, scanOption, VALUE_TYPE, "unknown", nil, nil, nil, nil, nil)
        if not beginSuccess then
            print("Error: BeginScan failed.")
            memscan.destroy()
            return false, nil
        end
    
        local updateSuccess = memscan.UpdateScan()
        if not updateSuccess then
            print("Error: UpdateScan failed.")
            memscan.destroy()
            return false, nil
        end
    
        local newFoundList = memscan.FoundList
        if not newFoundList then
            print("Error: FoundList is nil after narrow down scan.")
            memscan.destroy()
            return false, nil
        end
    
        -- No need to call newFoundList.Initialize()
    
        memscan.destroy()
    
        if newFoundList.Count > 0 then
            print(string.format("Narrow down scan successful. %d results found.", newFoundList.Count))
            return true, newFoundList
        else
            print("No results found in new FoundList after narrow down scan.")
            return false, nil
        end
    end
    
    -- Function to find a unique address by repeatedly narrowing down the scan
    function findUniqueAddress(initialScanOption, narrowScanOption, promptMessage)
        -- Perform initial scan
        local success, foundlist = initialScanUnknown(initialScanOption)
        if not success then
            print("Initial scan failed.")
            return nil
        end
    
        -- Repeat narrowing down until one address is found or no results remain
        while foundlist.Count > 1 do
            print(promptMessage)
            print("Please perform the required action in the game, then press Enter to continue...")
            io.read()
    
            -- Perform narrow down scan
            local successNarrow, newFoundList = narrowDownScanUnknown(foundlist, narrowScanOption)
            if not successNarrow then
                print("Narrow down scan failed.")
                foundlist.destroy()
                return nil
            end
    
            -- Destroy previous found list and update to new one
            foundlist.destroy()
            foundlist = newFoundList
        end
    
        -- Check if exactly one result is found
        if foundlist.Count == 1 then
            local address = foundlist:Address[0]
            if address then
                foundlist.destroy()
                print(string.format("Unique address found: 0x%X", address))
                return address
            else
                print("Error: Address list is invalid.")
                foundlist.destroy()
                return nil
            end
        elseif foundlist.Count == 0 then
            print("No addresses found.")
            foundlist.destroy()
            return nil
        else
            print("Multiple addresses found but unable to narrow down further.")
            foundlist.destroy()
            return nil
        end
    end
    
    -- Function to find the enemy's position
    function findEnemyPosition()
        print("Starting initial unknown scan for enemy X position...")
        local enemyXAddress = findUniqueAddress(
            soUnknownInitialValue,
            soUnknownValueChanged,
            "Change the enemy's position in-game and press Enter..."
        )
        if not enemyXAddress then
            print("Failed to find enemy position.")
            return nil, nil, nil, nil
        end
    
        print(string.format("Enemy X Address Found: 0x%X", enemyXAddress))
    
        -- Read Y and Z positions based on known offsets
        local enemyYAddress = enemyXAddress + 4  -- Assuming 4 bytes per coordinate
        local enemyZAddress = enemyXAddress + 8
    
        local enemyX = readValue(enemyXAddress, VALUE_TYPE)
        local enemyY = readValue(enemyYAddress, VALUE_TYPE)
        local enemyZ = readValue(enemyZAddress, VALUE_TYPE)
    
        if enemyX == nil or enemyY == nil or enemyZ == nil then
            print("Error: Failed to read one or more enemy position values.")
            return nil, nil, nil, nil
        end
    
        print(string.format("Enemy Position: X=%.2f, Y=%.2f, Z=%.2f", enemyX, enemyY, enemyZ))
        return enemyX, enemyY, enemyZ, enemyXAddress
    end
    
    -- Function to find the player's aim position
    function findPlayerAimPosition()
        print("Starting initial unknown scan for player aim X position...")
        local playerAimXAddress = findUniqueAddress(
            soUnknownInitialValue,
            soUnknownValueChanged,
            "Change the player's aim in-game and press Enter..."
        )
        if not playerAimXAddress then
            print("Failed to find player aim position.")
            return nil, nil, nil, nil
        end
    
        print(string.format("Player Aim X Address Found: 0x%X", playerAimXAddress))
    
        -- Read Y and Z positions based on known offsets
        local playerAimYAddress = playerAimXAddress + 4  -- Assuming 4 bytes per coordinate
        local playerAimZAddress = playerAimXAddress + 8
    
        local playerAimX = readValue(playerAimXAddress, VALUE_TYPE)
        local playerAimY = readValue(playerAimYAddress, VALUE_TYPE)
        local playerAimZ = readValue(playerAimZAddress, VALUE_TYPE)
    
        if playerAimX == nil or playerAimY == nil or playerAimZ == nil then
            print("Error: Failed to read one or more player aim position values.")
            return nil, nil, nil, nil
        end
    
        print(string.format("Player Aim Position: X=%.2f, Y=%.2f, Z=%.2f", playerAimX, playerAimY, playerAimZ))
        return playerAimX, playerAimY, playerAimZ, playerAimXAddress
    end
    
    -- Function to calculate the aim offset
    function calculateAimOffset(enemyX, enemyY, enemyZ, playerAimX, playerAimY, playerAimZ)
        -- Calculate the offset to aim at the enemy's head
        local offsetX = enemyX - playerAimX
        local offsetY = enemyY - playerAimY
        local offsetZ = enemyZ - playerAimZ
    
        -- Adjust the aim (this is a simple example, you may need to fine-tune the values)
        local newAimX = playerAimX + offsetX
        local newAimY = playerAimY + offsetY
        local newAimZ = playerAimZ + offsetZ
    
        return newAimX, newAimY, newAimZ
    end
    
    -- ==================== Main Loop ====================
    
    -- Function to safely destroy foundlist
    function safeDestroy(foundlist)
        if foundlist and foundlist.destroy then
            foundlist:destroy()
        end
    end
    
    -- Main loop
    while true do
        ::continue:: -- Label moved to the beginning of the loop
    
        -- Find the enemy's position
        local enemyX, enemyY, enemyZ, enemyXAddress = findEnemyPosition()
        if not enemyX or not enemyY or not enemyZ then
            print("Failed to find enemy position. Retrying in 1 second...")
            sleep(1000) -- Sleep for 1 second
            goto continue
        end
    
        -- Find the player's aim position
        local playerAimX, playerAimY, playerAimZ, playerAimXAddress = findPlayerAimPosition()
        if not playerAimX or not playerAimY or not playerAimZ then
            print("Failed to find player aim position. Retrying in 1 second...")
            sleep(1000) -- Sleep for 1 second
            goto continue
        end
    
        -- Calculate the aim offset
        local newAimX, newAimY, newAimZ = calculateAimOffset(
            enemyX, enemyY, enemyZ,
            playerAimX, playerAimY, playerAimZ
        )
    
        -- Write the new aim position back to memory
        writeValue(playerAimXAddress, newAimX, VALUE_TYPE)
        writeValue(playerAimXAddress + 4, newAimY, VALUE_TYPE)
        writeValue(playerAimXAddress + 8, newAimZ, VALUE_TYPE)
    
        print(string.format("Aim adjusted to X=%.2f, Y=%.2f, Z=%.2f", newAimX, newAimY, newAimZ))
    
        -- Sleep to avoid high CPU usage
        sleep(10) -- Sleep for 10 milliseconds
    end
    

    Key Changes Explained:

    1. Removed foundlist.Initialize():

      • Why: The FoundList is already initialized by FirstScan and UpdateScan. Calling Initialize() manually can interfere with its state.
    2. Enhanced readValue and writeValue Functions:

      • Added Support for vtDouble: In case the game uses double-precision floats for positions.
      • Improved Error Messages: More descriptive error messages to aid in debugging.
    3. Adjusted findUniqueAddress Function:

      • Corrected Address Retrieval: Changed foundlist.Address[0] to foundlist:Address[0] to align with Cheat Engine's API.
      • Added Handling for Zero Addresses: Explicitly checked if the address is valid before proceeding.
    4. Improved User Prompts:

      • Clarified Instructions: Made prompts clearer to ensure the user performs the necessary in-game actions before pressing Enter.
    5. General Debugging Enhancements:

      • Additional Print Statements: To provide better insights into each step of the scanning process.

    Additional Recommendations:

    1. Verify Memory Structure:

      • Use Cheat Engine's manual scanning features to confirm the memory layout of enemy and player positions. Ensure that the offsets (+4 and +8) are correct.
    2. Check Value Types:

      • If float values (vtFloat) aren't yielding results, try switching to double (vtDouble). Adjust the VALUE_TYPE accordingly.
    3. Ensure Proper Process Attachment:

      • Before running the script, confirm that Cheat Engine is attached to the correct game process with the necessary permissions.
    4. Handle Dynamic Memory:

      • Some games use dynamic memory allocations, which can change between sessions. Implement pointer scanning or use signature scanning to find consistent addresses.
    5. Consider Anti-Cheat Mechanisms:

      • Be aware that modifying game memory can trigger anti-cheat systems, potentially leading to bans or other penalties.
    6. Test Incrementally:

      • Start by verifying each function individually. For example, first confirm that findUniqueAddress works as expected before integrating it into the full script.
    7. Use Cheat Engine's Built-in Features:

      • Utilize Cheat Engine's manual scanning and pointer hunting before automating the process with Lua scripts. This can help identify any challenges specific to the game's memory structure.

    Conclusion

    The primary issue with your script stems from the improper initialization of the FoundList and potential mismatches in memory layout assumptions. By removing unnecessary initialization calls, verifying memory offsets, and enhancing debugging, you should be able to perform successful memory scans. Always ensure that your scripts align with the game's specific memory structures and handle edge cases gracefully.

    If you continue to face issues, consider providing more context or specific error logs, and we can delve deeper into potential solutions.