Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

spawn

spawn(name, opts) constructs a multiplayer-synced entity. It is identical to entity.spawn — same arguments, returns the same entity proxy — with one difference: the new entity is flagged synced, so the replication layer mirrors it to every connected peer and the relay persists it for late joiners.

It hardcodes nothing about the entity's contents. Add whatever components you want on the returned proxy, exactly as you would after entity.spawn.

Export

  • spawn(name?, opts?) -> entityProxy — spawn a synced entity. name and opts are forwarded verbatim to entity.spawn; the returned proxy is already flagged synced.

Usage

local e = spawn("crate")
e.component.add("Model", { model = "cube" })
e.position = { 0, 1, 0 }

Related primitives

  • entity(id):setSynced(true) — flag an existing single entity synced.
  • entity(root):setSyncedTree(true) — flag an existing hierarchy synced in one explicit call (root + every current descendant).
  • entity(id):setSynced(false) — opt an entity out of replication.

Sync is generic and entity-based: an entity replicates iff it carries the synced flag. spawn is just the convenience that sets that flag at construction time — nothing about it is specific to any component or content type.