# Globals

**Globals:**

`Globals.FetchDatamodel()`: Returns the root DataModel of the game. Use this to access every object and service within the game's hierarchy.

```lua
local dm = Globals.FetchDatamodel()
print(dm:Name())
```

`Globals.FetchLocalPlayer()`: Returns your specific player instance.

```lua
local lp = Globals.FetchLocalPlayer()
print(lp:Name())
```

`Globals.FetchLocalPlayerCharacter()`: Returns the local player's character instance directly without needing to go through the player object.

```lua
local char = Globals.FetchLocalPlayerCharacter()
print(char:Name())
```

`Globals.FetchWorkspace()`: Returns the Workspace service instance.

```lua
local ws = Globals.FetchWorkspace()
print(ws:Name())
```

`Globals.FetchLighting()`: Returns the Lighting service instance.

```lua
local lighting = Globals.FetchLighting()
print(lighting:Name())
```

`Globals.FetchPlayers()`: Returns the Players service instance.

```lua
local players = Globals.FetchPlayers()
print(players:Name())
```

`Globals.FetchLocalPlayerUserId()`: Returns the LocalPlayer UserID.

```lua
local LP_UserID = Globals.FetchLocalPlayerUserId()
```

`SetClipboard(string)`: Takes a string and saves it to your Windows clipboard so you can paste it elsewhere.

```lua
SetClipboard("Hello World")
```

`GetClipboard()`: Retrieves whatever text is currently copied to your Windows clipboard and returns it as a string.

```lua
local text = GetClipboard()
print(text)
```

`Game.ForceGameUpdate()`: Forces the game to re-invalidate the sky and lighting. Useful after making visual changes that need to be refreshed immediately.

```lua
Game.ForceGameUpdate()
```

`wait(seconds)`: Yields the current thread for the given number of seconds.

```lua
wait(1.5)
```

`tick()`: Returns the current time as a Unix timestamp in seconds with millisecond precision.

```lua
local t = tick()
print(t)
```

`print(message)`: Prints a string to the script console.

```lua
print("Hello World!")
```

`GetDeltaTime()`: Returns the time in seconds elapsed since the last call. Useful for frame-rate-independent movement and animations. &#x20;

```lua
local dt = GetDeltaTime()
```

`loadstring(code)`: Compiles and returns a Lua chunk from a string. Returns the function on success, or `nil` and an error message on failure.

```lua
local fn, err = loadstring("print('hello')")
if fn then fn() end
```

`run_secure(code)`: Executes a Lua string or bytecode in a sandboxed environment. Dangerous globals like `os`, `io`, `require`, and `debug` are stripped. Returns `true` plus any results on success, or `false` and an error message on failure.

```lua
local ok, err = run_secure("print('hello')")
if not ok then print("Error:", err) end
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yerba-1.gitbook.io/yerba-docs/api/editor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
