Testing and debugging
KHIM Engine runs your world exactly as a game server and a player's app would - the same physics, the same scripts, the same HUD - so most bugs show up before anyone else plays.
Three ways to test
| Key | What it runs | |
|---|---|---|
| Play | F5 | A server and one player: your character appears at the spawn |
| Play Here | The same, with your character where the camera is | |
| Run | F8 | The server only, no character: watch physics and Scripts from the editor camera |
| Stop | Shift F5 | Ends the test and puts the world back as it was |
| Restart | Ctrl Shift F5 | Stop, then the same kind of test again |
While a test runs, the world is read-only: Save, Undo and editing wait until you stop. Nothing a test does is kept.
During a test the Hierarchy shows what the player has: ServerService and StorageService are empty and marked "server only", and server Scripts are hidden. A ClientScript in a test can't reach anything a real player couldn't - so a test never passes for the wrong reason.
Select your character's Body in the Hierarchy to change Health, WalkSpeed and JumpPower while the test runs: try values before writing them into a script.
The Console
Ctrl J. Starting a test brings it forward.
- Server output is green, the player's (ClientScripts) blue, warnings orange, errors red.
- Every line says where it came from -
[Coins:12] text- and clicking it opens that script at that line. - Messages, Warnings and Errors toggle with their counts; the search looks through text and source.
- A script error is split into: the error (a link to the line), what it usually means in plain words, and Show the calls that led here for the call stack.
For example attempt to index nil with 'parent' comes with: what was before .parent is nil: that object is not there (yet), or its name is spelt differently. Check the name in the Hierarchy, or wait for it with :waitFor("Name").
Copy and Export take the lines shown.
The Command Line
Under the Console. Luau typed there runs straight away - on the world being edited, or on the test while one runs:
for _, p in world:children() do if p.name == "Coin" then p.color = rgb(255, 200, 0) end endProblems
The Problems tab (beside the Console) lists every script's errors and warnings at once, open or not: syntax errors, the error each script stopped with in the last test, lint warnings and type problems. Click one to open the script at the line. Run > Check all scripts checks them all.
As you type, the editor marks problems in place:
- Red squiggle - an error: a syntax error, or a value of the wrong type.
- Amber - a warning: a name that isn't defined (with the one you probably meant:
'pirnt' is not defined; did you mean print?), a misspelt member of a library, unreachable code... --!nolintat the top of a script turns lint warnings off;--!strictchecks every type,--!nochecknone.
The debugger
Breakpoints, pausing and stepping, on the server's Scripts and the player's ClientScripts alike.
- Click in the narrow gutter between a line's number and its text, or press F9 on the line: a red dot.
- Press F5. When a script reaches the line, the whole test stands still - physics, the character, every script - and the Debugger panel opens.
- Read the Call Stack and Variables (locals, upvalues, globals; open tables and objects with the arrow).
- Carry on:
| Key | |
|---|---|
| Continue | F5 |
| Pause | F6 |
| Step over | F10 |
| Step into | F11 |
| Step out | Shift F11 |
With Stop on errors on (the default), a script error also stops the test at the line that failed, its variables ready to read. Right-click a breakpoint to turn it off without removing it.
How heavy is it?
F3 shows, over the view: frames a second, the milliseconds of work in each frame, the parts drawn and the draw calls they took. During a test a second line names the four busiest scripts: Scripts 0.42 ms a frame: Coins 0.30 Shop (client) 0.08.
On a live game, the Workshop's Live page shows each session's loop time and script memory, and its Console names a script that takes a big share of a processor.
Testing with more players
Play is one player. To see what two players see - a trade, a fight, a shared door - go live (the game can stay private) and join from two devices, or from the KHIM app and the browser.
Logs
If KHIM Engine closes or a shader won't compile, the reason is in runtime/studio/studio_log.txt inside its install folder (%LOCALAPPDATA%\KHIM Studio on Windows). The run before is kept as studio_log.old.txt.