Reference/Troubleshooting
| Symptom | Likely cause |
|---|---|
| My function never runs | The name is not exactly the event name (events are case sensitive: onPlayerSpawn), the file is missing from Script.xml, or the script folder is not in content.xml. Check the server console for a compile error. |
Property read returns null | Misspelled property, or the entity no longer exists. Properties are case sensitive (Pos, not pos). |
| Setting a vector field does nothing | player.Pos.x = 1 changes a temporary copy. Read the vector into a local, change it and assign it back. |
CallServerFunc does nothing | The server did not call RegisterRemoteFunc("name"), or the function is not global, or it is not connected yet. |
CallClientFunc does nothing | The function is not global in a client script, or the script has not finished downloading (wait for the player to join). |
| GUI is not visible | The element was not added with AddGUILayer, a window's child was not attached with AddChild, or Visible is false. |
| Buttons cannot be clicked | Call ShowMouseCursor(true) while the menu is open. |
| Players walk around behind my menu | Call ToggleCameraMovement(false) while it is open and true when closing. |
| Timer not firing | The callback is a local function, or its name is wrong. Timers look up a global function by name. |
| NPC will not shoot | It has no ammo: use npc.SetWeapon(id, ammo) and OBJ_ATTACK_PLAYER. |
| Sounds only play on the server PC | Server FindSound plays on the server machine. Use <sound> in Script.xml and the client FindSound. |
- Do heavy work in timers, not in
onPlayerUpdate/onVehicleUpdate; those run for every sync packet. - Always validate entities (
if (p)) obtained from ids, and remove per-player table entries inonPlayerPart. - Never trust numbers coming from
CallServerFunc: clamp them, check that the player is allowed to do it, and never reward the player only because the client said so. - Keep the chat clean: use
MessagePlayerfor personal replies andMessageonly for events everybody should see. - Test with
ReloadScripts()while developing; typingreloadinto a console-input handler is convenient.
Categories: Troubleshooting and good habits