Luduvo Contents
Theme
On this page

Prefabs

spawns saved prefabs by name and translates between prefab names and their numeric ids

Methods

4 members Access: shared

Exists(name: string) -> boolean

whether a prefab exists

Parameters
NameTypeDescription
namestringPrefab template name to check.
returnsboolean—
Id(name: string) -> number

lookup a prefab numeric id by name

Parameters
NameTypeDescription
namestringPrefab template name to look up the numeric identifier for.
returnsnumber—
Name(id: number) -> string?

lookup a prefab name by numeric id

Parameters
NameTypeDescription
idnumberNumeric prefab identifier to look up the template name for.
returnsstring?—
Spawn(name: string) -> Instance?

spawn a prefab by name

Parameters
NameTypeDescription
namestringPrefab template name to instantiate.
returnsInstance?—

Spawning Prefabs into the World

Lifecycle: Server

Check that a template exists before spawning it, then parent the copy into the world.

Luau
if game.Prefabs.Exists("Lantern") then	local lamp = game.Prefabs.Spawn("Lantern")	if lamp then		lamp.Parent = game.World		print("Spawned prefab:", lamp.Name)	endend
Output: Spawned prefab: Lantern