World
iterates the entities of the running place and registers the systems that run over them every tick
Methods
4 members Access: shared
- DumpAttributes
(entity: Instance?) -> () print attribute usage to the output
Parameters
Name Type Description entity Instance? Entity instance to inspect. returns () — - Each
(component: string) -> () -> Instance? iterate the entities that hold a component
Parameters
Name Type Description component string Component type to iterate over active entities. returns () -> Instance? — - Query
(...string) -> Query build a cached multi-component query
Parameters and example
Name Type Description ...string any Component names required by the query filter. returns Query — local query = game.World.Query("Tool") local count = query:Refresh() print("Matched tools count:", count) for i = 1, query.count do local entity = query.Entity[i] print(string.format("Slot %d entity: %s", i, tostring(entity))) end- System
(name: string, q: Query, fn: (Query) -> (), phase: string?) -> () register a per-tick system over a query
Parameters
Name Type Description name string Unique system identifier reported in profiler stage metrics. q Query Query selecting the entities and component arrays to iterate. fn (Query) -> () Callback invoked each tick with the query instance. phase string? One of "Default" or "Physics"; nil selects "Default". returns () —
Running ECS Simulation Systems
Lifecycle: Server
A query paired with a system is the standard way to run per-tick logic over a set of entities.
Luau
local pickups = game.World.Query("Tool", "Position")game.World.System("pickup_simulation", pickups, function(q) for i = 1, q.count do local entity = q.Entity[i] local position = q.Position[i] local count, hits = game.Physics.OverlapBox(position, Vector3.new(1, 1, 1)) for h = 1, count do -- Handle pickup collision interaction end endend)