Skip to content

World Module

STBrian edited this page Nov 9, 2026 · 2 revisions

The World submodule provides functions to query and modify blocks in the world, inspect player raycast targets (blocks and entities), manipulate weather conditions and cloud height, play sounds, and detect when worlds are joined or left.

Events

Game.World.OnWorldJoin Triggered when the player loads and enters a world
Game.World.OnWorldLeave Triggered when the player leaves or exits a world

Properties

Loaded boolean Read-only. Whether a world is currently loaded
Raining boolean Whether rain weather is active
Thunderstorm boolean Whether thunderstorm weather is active
CloudsHeight number Vertical height offset of cloud rendering
Weather WeatherType Active weather enum state (WeatherType)

Functions

Game.World.message Displays an in-game HUD notification
Game.World.getTargetEntity Returns the entity the player is crosshair-aiming at
Game.World.getTargetBlock Returns block coordinates the player is crosshair-aiming at
Game.World.getBlock Retrieves the block ID and data at coordinates
Game.World.setBlock Places or changes a block at coordinates
Game.World.getCurrentBiome Returns the biome ID of the player's current location
Game.World.playGlobalSound Plays an audio sound effect globally

Game.World.OnWorldJoin

Fires as soon as the player finishes loading and enters a Minecraft world.

Game.World.OnWorldJoin:Connect(function()
end)

Example

Game.World.OnWorldJoin:Connect(function()
    Game.World.message("Welcome back to your world!")
end)

Game.World.OnWorldLeave

Fires when the player saves, leaves, or quits the current world to the main menu.

Game.World.OnWorldLeave:Connect(function()
end)

Game.World.message

Pushes an in-game message notification banner to the top screen HUD. Returns true if displayed successfully.

Game.World.message(msg: string) -> boolean

Game.World.getTargetEntity

Returns the GameEntity that the player is looking at, or nil if not looking at an entity.

Game.World.getTargetEntity() -> GameEntity?

Game.World.getTargetBlock

Returns a table with x, y, z integer coordinates of the block currently targeted by the player's crosshair, or nil if looking at the sky or outside raycast range.

Game.World.getTargetBlock() -> {x: integer, y: integer, z: integer}?

Example

local target = Game.World.getTargetBlock()
if target then
    local id, data = Game.World.getBlock(target.x, target.y, target.z)
    Core.Debug.message(string.format("Looking at block %d:%d at (%d, %d, %d)", id, data, target.x, target.y, target.z))
end

Game.World.getBlock

Reads and returns the block ID and data/variant at the specified (x, y, z) world coordinates.

Game.World.getBlock(x: integer, y: integer, z: integer) -> integer, integer

Game.World.setBlock

Sets the block at the specified (x, y, z) coordinates to blockId with blockData. Automatically scheduled safely on the game's main engine thread.

Game.World.setBlock(x: integer, y: integer, z: integer, blockId: integer, blockData: integer)

Example

-- Place a diamond block (ID 57) 2 blocks beneath the player
local px, py, pz = Game.LocalPlayer.Position.get()
Game.World.setBlock(math.floor(px), math.floor(py) - 2, math.floor(pz), 57, 0)

Game.World.getCurrentBiome

Returns the integer biome ID where the local player is currently situated, or -1 if unavailable.

Game.World.getCurrentBiome() -> integer

Game.World.playGlobalSound

Plays a global sound effect by its string sound ID with volume and pitch settings.

Game.World.playGlobalSound(soundId: string, volume: number, pitch: number)

Example

Game.World.playGlobalSound("random.levelup", 1.0, 1.0)

Clone this wiki locally