[Solved] Calling client side event not working

Dear Community,

I am working on modifying the scoreboard to disable it when inside a menu for example a mod menu.
I have this code on the server side (which i can call with out any issue):

RegisterServerEvent('lockScoreBoardS')
AddEventHandler('lockScoreBoardS', function()
	print(source)
	TriggerClientEvent("lockScoreBoardC")
	print('just called lockScoreBoardC')
end)

and this code in the Scoreboard file:

RegisterNetEvent("lockScoreBoardC")
AddEventHandler("lockScoreBoardC", function()
	print('client side of scoreboard')
	if listDisable then
		listDisable = false
		drawNotification("Scoreboard Enabled")
	elseif not listDisable then
	    listDisable = true
		drawNotification("Scoreboard Disabled")
	end
end)

The Server side code is inside a trainer folder and the scoreboard files are in the usual [system]/Scoreboard folder.

Any help gratefully appreciated

When you trigger a client event you need to specify a netid otherwise the server doesn’t know who to send the event to.

Hello and thank you for your reply, So do you mean I should be doing something like this:

TriggerClientEvent("lockScoreBoardC", ServerID)

or should it be

TriggerClientEvent("lockScoreBoardC", source)

Thank you for your time.

If you want to call it on the client that triggered the server event you can use source.

Ahh all this time i spent trying things and then in two messages you solve the issue. THANK YOU so much! :grinning:

1 Like