Client Script not Working

Hey. Bit of background, I’m trying to develop a script that can automatically register a vehicle within our CAD system. We’re in need of a character switch system however. I started making this client script based off NativeUI and their MenuExample.lua but I’m not sure if I have done something drastically wrong or it just isn’t executing anything. I have put it in the fxmanifest.lua file (keep in mind that I haven’t used this new system but nothing much really has changed and I added everything mentioned in the docs)
and I’ve cleared my cache several times.

Here is my cl.lua (I have placed various different prints to the console to see where it was going wrong but absolutely none of them printed to the console, in-fact, I don’t get anything but a resource start message)

print("Debug 1")

menuPool = NativeUI.CreatePool()
main = menuPool.CreateMenu("Switch Character", "Test Menu")
menuPool:Add(main)

function AddMenuCharacter(menu, character)
    local newitem = NativeUI.CreateItem(character, "Switch your character to " .. character)
    menu:AddItem(newitem)
    menu.OnItemSelect = function(sender, item, index)
        print("Switch request to " .. character)
    end
end

AddMenuCharacter(main, "Test Character")
menuPool:RefreshIndex()

Citizen.CreateThread(function()
    print("Debug 2")
    while true do
        Citizen.Wait(0)
        menuPool:ProcessMenus()
        print("Debug 3")
        if IsControlJustPressed(1, 51) then -- 'E' key
            print("Debug 4")
            main:Visible(not mainMenu:Visible())
        end
    end
end)

None of this is functional in-game and I’m a bit concerned. My server script I have works totally fine however. I have no idea why. Here is my fxmanifest:

game 'gta5'
fx_version 'cerulean'

server_script '@mysql-async/lib/MySQL.lua'

server_script 'sv.lua'
client_scripts {
    "@NativeUI/NativeUI.lua",
    "cl.lua"
} 

Here is my server.cfg order too if it matters (if you hadn’t gathered, the resource is called registercar):

ensure NativeUI
ensure mysql-async
ensure registercar

If anybody has any ideas, whether it may be me making a really stupid mistake or if this actually just isn’t working, please let me know.

TIA,
James

Could I see a photo of the filestructure? Like from wi

Hey, sorry I didn’t see, I’ve been quite busy today.

Here it is:

Not a single one of the debug prints happens, correct?

Yup, absolutely nothing prints to the console. The console says that the resource starts correctly too. It’s almost as if the script doesn’t exist

If you remove everything from the file & just add a print, does it print?

Using only print("test") in the cl.lua file still doesn’t print anything to the console.
image
It still says that it’s running just fine and my sv.lua file still runs fine. I’m rather confused too because on command execution in my server script, it prints to the console with the result of what I was testing.

Either the client script still isn’t executing or print() doesn’t work in client scripts for whatever reason and there’s something wrong with my NativeUI script.

I found the issue here. Usually when I used print, it outputs to the server console but I personally didn’t realize that the client script print outputs the F8 console. It’s been a while since I’ve made scripts for FiveM :sweat_smile:

Sorry if I wasted any of your time. PSA: client script print()s output to F8.

1 Like