Your first script
A script is a folder in scripts/ that contains a main.luau file.
1. Create the script#
scripts/hello/main.luau:
on("playerJoin", function(player)
log(player.name, "joined")
wait(2)
if player:exists() then
player:emit("message", "Welcome to Noverwyn, " .. player.name .. "!")
end
end)
2. Start it#
In the console:
start hello
To start it automatically, add it to server.json:
"scripts": { "start": ["school", "vip", "hello"] }
3. Edit it live#
Change the file, then:
restart hello
Players stay connected. playerJoin is not replayed for them: if your script needs it, go through players.all() at startup.
4. Add a zone#
zones.sphere({
name = "Fountain",
center = { 0, 30, 0 },
radius = 4,
onEnter = function(zone, player)
player:emit("message", "You can hear the fountain.")
end,
})