Server
Server is not creatable, there's only one instance of it. It can only be accessed through its globally exposed variable.
The Server acts as a host and director for the game.
For example, if your game requires a minimum amount of players, it's a good idea to use the Server to count and trigger game start.
Properties
Executed when a Player joins the Server.
Server.OnPlayerJoin = function(newPlayer) print("Welcome", newPlayer.Username) end
Executed when a Player leaves the Server.
Server.OnPlayerLeave = function(leavingPlayer) print(leavingPlayer.Username, "has left") end
Executed when the Server starts.
Server.OnStart = function() -- initialize Server scores = {} -- Server-only variable for i = 0, 15 do scores[i] = 0 end end
Executed ~30 times per second. Provides the elapsed time in seconds as parameter.
-- executed ~30 times per second on each user device Server.Tick = function(dt) print("elapsed:", dt, "seconds") end