I’ve been trying to fix this for 2 days straight and I must be fundamentally misunderstanding this because it just won’t work no matter what I do. I made an entirely new resource JUST to test this and it still doesn’t work.
I’m trying to trigger a server event when the E key is pressed (no other conditions for now, I just want it to work first). I’ve tried using both a while loop with IsControlJustPressed, and used RegisterKeyMapping - neither of them work.
If I trigger the event with a command it works, so it’s not that the server.lua isn’t being executed. It’s only when I do it with a key press that it stops working. Also, I’m not checking the wrong console, I’m looking in the server console and nothing shows up when I press E.
Got desperate enough to spend like 1.5h with ChatGPT to help with troubleshooting… still couldn’t get it to work.
I have now also tried:
Updating server to build 14482 (which just broke my ScriptHookV mods, good thing I made a backup)
Changing back to IsControlJustPressed again, it still just detects the key press but doesn’t trigger anything server-side
Setting sv_lan to 0
On key press, triggering a client event, which in turn triggers the server event - that ALSO didn’t work
Trying other keys than E, no difference
Either I must be completely stupid or there’s something very wrong with my server.
EDIT: Okay this just got even more confusing… I was playing on the server, pressed E and randomly in console I see the event triggered? It’s like its only triggering the event on certain frames or something, this makes no sense.
Oh my god… I found the problem and I now also want to jump of the nearest bridge.
Apparently last month I had made a script that was triggering server events in a while loop… EVERY FRAME. This script was taking up the entire budget of server events, stopping all other server events from going through.
I disabled that script, now every problem I mentioned is solved, all other server events trigger. I wasted days on trying to solve this, I even downloaded a new server to see if that was the problem.