Testing and Debugging Games
Testing and Debugging Games
It’s not always possible to write functional scripts the first time, or even figure out the problem by looking at them. Sometimes you need to “debug” a script by using techniques and tools which provide more information about what went wrong.
Pressing the Run button in Studio simulates a Roblox server running your game without any players. This is useful if you want to quickly test how your game starts up and runs scripts that don’t involve players.
Pressing the Play or Play Here button in Studio simulates a server running with a single player that you control. This is useful for quickly testing player actions in your game.
Pressing Start in the Test tab of Studio creates a simulated server much like Run does. With Start, however, you can also specify the number of generic players to add to the game. A new instance of Studio will launch for each player, and one for the server. This mode very closely simulates your game running on Roblox and is ideal for testing multiple player interactions and client-server features like
Roblox has a number of debugging tools that can help you analyze failing (or working) scripts.
The Output window is one of the most powerful debugging tools. It displays any errors captured from running scripts, messages from Roblox game code, and user-defined messages and errors. It can be useful to include
print() calls at key places in your scripts so you can see messages in the Output window.
To open the Output window in Studio, click on the View tab and then on Output.
Like most IDEs, Roblox Studio includes a
Articles/Lua debugger you can use to pause a script so you can inspect it while it is running. This allows you to stop a script at specific points and run it step by step to see how it behaves.
The Command Bar in Studio provides a powerful debugging tool. It allows you to test out possible script commands and to make adjustments to the game while it’s running.
The Explorer and Properties windows can be used in Studio to see what objects exist at a given time. This can help you see if certain properties were inadvertently changed by a script.
Whenever a script running on your computer prints or has an error, that message is recorded in a log file. These files are located in different places depending on the operating system:
- On Windows, type
%LOCALAPPDATA%\Roblox\logsinto the file explorer address bar and then sort the folder by date modified. Logs should have the format
log_XXXXXfollowed by additional naming. All logs with the same
XXXXXvalue are from the same Studio session.
- On macOS, logs are in the directory
~/Library/Logs/Roblox. In the Finder, click the Go menu, select Go to Folder, type in that directory, and confirm.