• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Globals

    Scene

    Inherits from:

    The global scene object represents the current world scene. Scenes allow you to section your world into different areas with separate player management.

    Use cases:

    • Access players in the current scene (scene.players, scene.playerCount)
    • Listen for players joining or leaving the scene
    • Get the scene's main camera (client-side)
    • Instantiate scene prefabs (server-side)
    • Access scene name and ID

    Example usage:

    Properties

    PlayerJoined

    ClientAndServer
    ReadOnly

    An event triggered when a player joins the scene.

    PlayerLeft

    ClientAndServer
    ReadOnly

    An event triggered when a player leaves the scene.

    id

    number
    ClientAndServer
    ReadOnly

    A unique identifier for this scene instance. This id indicates the order in which the scene was instantiated, not where it appears in the World Settings scene list. You can use scene.name to get that identifier.

    mainCamera

    ClientOnly
    ReadOnly

    The main camera associated with the scene.

    name

    string
    ClientAndServer
    ReadOnly

    playerCount

    number
    ClientAndServer
    ReadOnly

    players

    ClientAndServer
    ReadOnly

    Methods

    Returns

    void

    Instantiate

    ServerOnly

    Instantiates a scene prefab at the specified position and rotation. The owner parameter determines which player "owns" the instantiated scene.

    IMPORTANT: Server-side only.

    Available on: Server only

    --!Type(Server)
    
    function self:ServerStart()
        server.PlayerConnected:Connect(function(player)
            -- Create a personal scene instance for the player
            local personalScene = scene.Instantiate(
                scenePrefab,
                Vector3.new(0, 0, 0),
                Vector3.new(0, 0, 0),
                player
            )
            
            print("Created personal scene for " .. player.name)
            
            -- Move player to their personal scene
            server.MovePlayerToScene(player, personalScene)
        end)
    end
    

    Parameters

    prefab
    position
    rotation
    owner

    Returns

    MarkLoaded

    ClientOnly

    Returns

    void

    Updated 19 days ago

    PocketWorlds Icon

    © 2025 Pocket Worlds. All rights reserved.