ReferenceMulti-instance

apex.ipc.invoke

Calls another instance's handler and waits for its answer.

Syntax

apex.ipc.invoke(target: Peer | number | string, topic: string, ...: any) -> ...any

Parameters

ParameterTypeDescription
targetPeer, number or stringThe instance to call.
topicstringA topic the target answers with apex.ipc.handle.
...anyValues passed to the handler.

Returns

TypeDescription
...anyWhat the handler returned.

Description

The calling thread yields until the answer arrives. It raises an error when the target is not in a game, has no handler for the topic, its handler fails, it leaves before answering, or 30 seconds pass. Values follow the rules of apex.ipc.send, both ways.

Example

local ok, items = pcall(apex.ipc.invoke, "FarmAccount2", "inventory", "tools")
if ok then
    print("FarmAccount2 has", #items, "tools")
else
    warn(items)
end

These are Game executor contracts. Check build requirements and session lifetimes before using them.