SpawnMonster
spawnMonster
Creates a server-owned monster and replicates it to interested players.
Syntax
string|false spawnMonster(string type, number x, number y, number z [, number yaw = 0] [, table options])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type |
string |
yes | A stable type key from Monster type catalog. |
x |
number |
yes | World X coordinate in metres. |
y |
number |
yes | World Y coordinate in metres. |
z |
number |
yes | World Z coordinate in metres. |
yaw |
number |
no | Initial yaw in degrees. |
options |
table |
no | Optional table. Set aggressive to false to create a passive monster.
|
Returns
Returns the new opaque monster identifier string, or false when validation or spawning fails.
Examples
Spawn a passive scavenger:
local monsterId = spawnMonster("scavenger", 15.0, -4.5, 2.0, 90, { aggressive = false })
if monsterId then
outputDebugString("Spawned monster " .. monsterId)
end
Notes
- Available only in server-side resource scripts.
- The server owns identity, AI state, targeting, health, damage, relevance, and late-join replication.
- Spawning an unsupported type or exceeding the server monster limit returns false.
- See Monster type catalog for every currently supported type key.