Client scripts does not initialize

I have no idea why this is happening, but it’s like the client scripts don’t work. The print is never displayed in the console.

Client

TriggerServerEvent('testingEvent', 'SENT FROM CLIENT')

Server

RegisterServerEvent('testingEvent')
AddEventHandler('testingEvent', function(string)
	print(string)
end)

Resource file

-- Server
server_scripts { 
	'server/base.lua'
}

-- Client
client_scripts {
	'client/base.lua'
}

Put the TriggerServerEvent in a thread, like this:

Citizen.CreateThread( function()
    Citizen.Wait( 100 )
    TriggerServerEvent('testingEvent', 'SENT FROM CLIENT')
end )

Still nothing unfortunatly.

Strange, I just set up a test resource with the code you posted and it worked fine for me.

test.zip (1.2 KB)

The server file will print to the command prompt that runs the server, if you are checking the in game console that could be the issue.

Just tried installing that test resource and it’s still not working.

@TheStonedTurtle
I only check the server console.

That’s really odd, the same resource works for me, you are actually joining the game right? And what server are you using?

It is, and yes I am.

I am using FXServer.

It could be (I’m not 100% sure) that “string” is a reserved keyword in Lua (especially in CFX) so, the script could be getting confused with the string keyword and the string variable.

Try defining the event with a different parameter name. E.g.

AddEventHandler("event", function(str)
    print("str = " .. str)
end)

Tried this aswell, still nothing.

You definitely added start <resource> to the cfg file? It should say in console that the resource has been started.

Also, make sure you’re running the server with the +exe server.cfg argument to make sure that the config is being loaded :slightly_smiling_face:

Yes I definetly have that, as the resource starts and can do server stuff, but as soon as client stuff gets envolved it does not work. It does not Server to Client either.

Hmm… The only times I’ve had client scripts not work is when there’s been an error in the client script but, since you’ve only got the event call I can’t see that being an issue…

Have you tried putting it into a playerSpanwed event and seeing if that works? If not, try and have a look in the client logs to see if they give a clue as to where the problem lies.

AddEventHandler('playerSpawned', function()
	TriggerServerEvent('testingEvent', 'SENT FROM CLIENT WORKS')
end)

I added this, and that’s not even working.

EDIT: Wait, forgot to connect to the server properly.

EDIT 2: Nope, still nothing.

1 Like

Havoc helped me fixed the issue!

If anybody else has this issue I recommend you try and clean your cache, and if that doesn’t work try reinstalling the FXServer.