When discussing .js scripting within FiveM an important distinction to make is if the .js is running as an HTML source “file”, or if it is running directly on the client as a “script”.
With you speaking of an inventory, and you having added slots, I will assume the .js file is running as an HTML source, and is using some logic such as

window.addEventListener('message', function(event) {

and this is how HTML .js files listen for data from the client .lua scripts, you can find more detailed information here Fullscreen NUI - Cfx.re Docs

.js scripts that are running directly on the client will use emit and onNet, you will have to look further into how to properly use .js scripts here Creating your first script in JavaScript - Cfx.re Docs

2 Likes