Write Your First Script
Write and run your first script in server.ts: import the Jamango API, send a chat message, then switch from onGameStart to onPlayerJoin to greet every player who joins.
Script
Hello you mangoes and welcome back to Jamango! Academy!
After completing this video, your game will greet every player who joins it. No worries if you don't have much programming experience — this series is all about learning how to make fun games using Jamango, so let's get started with understanding: Scripts!
In Jamango, scripts are files that control how the game behaves. You can use them to do essentially anything, from spawning objects to detecting collisions (which we'll look at later in the series).
Code in Jamango is written using TypeScript — like JavaScript, but with a few extra features. The community nickname is MangoLango, and it includes special APIs for Jamango games.
To open the scripts menu, press H on your keyboard. By default you'll see two scripts: server.ts (runs on the game server, authoritative world logic) and client.ts (runs for each player, e.g. UI). For this video, open server.ts. At the top you'll see an import that loads the Jamango API — keep it there.
tsimport * as J from "jamango";
We want to send a message in chat when any player joins our obby game. There's some default code here that almost does what we want — let's break it down.
tsJ.onGameStart(() => { J.sendChatMessage("Hello Jamango!"); });
J.onGameStartdetects when the world starts for the first time.- Inside,
J.sendChatMessageposts a message to the in-game chat. - The text in quotes controls the message, and the semicolon ends the statement.
Try personalizing the message:
tsJ.onGameStart(() => { J.sendChatMessage("Welcome to my Obby!... good luck :)"); });
Save your script (Ctrl+S) and press TAB to run. You'll see the message appear in chat.
However, there's a catch: onGameStart only runs once when the server starts. In multiplayer, players join at different times, so we want a hook that runs for each new player.
Replace onGameStart with onPlayerJoin to greet every player as they enter the world:
tsJ.onPlayerJoin(() => { J.sendChatMessage("A New Player Dares to Attempt the Obby… >:)"); });
And there we go! In this lesson you've used J.onGameStart, J.onPlayerJoin, and J.sendChatMessage. In the next video, we'll build on these concepts and combine them with traits to create a spinning platform for our obby course.
As always, share progress in #creator-logs on Discord, ask questions, and keep experimenting!