[HELP] Notifications not when showing when a player spawns/respawns

Hello,

I’ve been trying to make a script that shows two notifications after someone spawns/respawns, one stating that the a connection is being established and one 3 seconds after saying connection established, but the notifications do not show up when I spawn in nor respawn. Help?

Code:

AddEventHandler('playerSpawned', function(spawn)
    local playerName = GetPlayerName(PlayerId())
    
    showAdvancedNotification(
        'Connecting PDA to network...',
        'PDA Network',
        'Establishing Connection...',
        'CHAR_GANGAPP',
        8,
        true,
        11
    )

    Citizen.Wait(3000)

    showAdvancedNotification(
        'Done! Welcome to the zone ' .. playerName .. '.'
        'PDA Network',
        'Connection Established!',
        'CHAR_GANGAPP',
        8,
        true,
        11
    )
end)

function showAdvancedNotification(message, sender, subject, textureDict, iconType, saveToBrief, color)
    BeginTextCommandThefeedPost('STRING')
    AddTextComponentSubstringPlayerName(message)
    ThefeedNextPostBackgroundColor(color)
    EndTextCommandThefeedPostMessagetext(textureDict, textureDict, false, iconType, sender, subject)
    EndTextCommandThefeedPostTicker(false, saveToBrief)
end

[Edit: I am new to scripting in general so there may be an obvious answer I did not know of]

Hello, you can place a print at the beginning and one at the end with different texts to see if the script reads the code when spawning, check the console.

Remember that if the script is client side the print will appear in the f8 and if it is server side it will appear in the server console.

This error shows up in the console, and thus does not start the client script.


Though, correct me if I’m wrong, there isn’t any problems with the code? Because the same function will be run once before line 18, I do not see why it wouldn’t work on the following repeat of the function. Maybe the wait time has something to do with it?
(Updated Code)

AddEventHandler('playerSpawned', function(spawn)
    local playerName = GetPlayerName(PlayerId())
    
    print('PDAStartconnect')

    showAdvancedNotification(
        'Connecting PDA to network...',
        'PDA Network',
        'Establishing Connection...',
        'CHAR_GANGAPP',
        5,
        true,
        11
    )

    Citizen.Wait(3000)

    showAdvancedNotification(
        'Done! Welcome to the LS exclusion zone, ' .. playerName .. '.'
        'PDA Network',
        'Connection Established!',
        'CHAR_GANGAPP',
        5,
        true,
        11
    )

    print('PDAEndconnect')

end)

function showAdvancedNotification(message, sender, subject, textureDict, iconType, saveToBrief, color)
    BeginTextCommandThefeedPost('STRING')
    AddTextComponentSubstringPlayerName(message)
    ThefeedNextPostBackgroundColor(color)
    EndTextCommandThefeedPostMessagetext(textureDict, textureDict, false, iconType, sender, subject)
    EndTextCommandThefeedPostTicker(false, saveToBrief)
end

I’ve found another thing, when I run the function once it works perfectly fine, but not when it is supposed to run twice