Skip to main content

SafeAreas

Places agents never go. Tag a part VLUXYAI_SAFE and it is a safe area for as long as its VLUXYAI_SAFE/Enabled attribute is not false; set the attribute to switch it off and on. Call SafeAreas.Setup once on the server so the part gets its navmesh modifier and is solid to agent rigs. The rest is automatic: Navmesh never plans through an enabled area, Straight never walks a line across one, Graph skips nodes in one when given Avoid = SafeAreas.Contains, and a player standing in one is left out of Perception.AliveRoots, so no sense targets them.

VluxyAI.SafeAreas.Setup({ RigGroup = "Monsters" })

Properties​

TAG​

SafeAreas.TAG: "VLUXYAI_SAFE"

ENABLED_ATTRIBUTE​

SafeAreas.ENABLED_ATTRIBUTE: "VLUXYAI_SAFE/Enabled"

false switches an area off. Missing means on.

LABEL​

SafeAreas.LABEL: "VLUXYAI_SAFE"

The PathfindingModifier label SafeAreas.Setup gives an enabled area, and the cost Navmesh prices at math.huge.

Functions​

IsEnabled​

SafeAreas.IsEnabled(part: Instance) → boolean--

false only when VLUXYAI_SAFE/Enabled is false.

InBox​

SafeAreas.InBox(
cframe: CFrame,--

The box's CFrame.

size: Vector3,--

The box's size.

point: Vector3
) → boolean--

true when point is inside the box, rotation included.

Pure.

Contains​

SafeAreas.Contains(point: Vector3) → (
boolean,--

true when point is inside an enabled safe area.

BasePart?--

That area.

)

The check every layer uses. A floor position counts as inside a room whose part reaches the floor; give a safe part a little depth below the floor if yours sits on it exactly.

Refresh​

SafeAreas.Refresh() → ()

Makes safe areas solid to the rig group and to no other collision group, including groups registered since SafeAreas.Setup (a new group collides with everything by default). Setup calls it, and so does every safe area added later; call it yourself after registering a collision group of your own.

Setup​

SafeAreas.Setup(options: SafeAreaSetupOptions?) → Cleaner--

Destroy it to stop watching the tag.

Types

​

interface SafeAreaSetupOptions {
RigGroup: string?--

The collision group your agent rigs are in. A safe area is solid to it and to nothing else. Default Collision.RIG_GROUP, the group Collision.AddRig puts rigs in.

}

Server setup, once. Every tagged part, now and later, gets a PathfindingModifier (labelled VLUXYAI_SAFE while enabled, so Navmesh prices it out) and goes in a collision group that only collides with RigGroup, solid while enabled and not while off. Players and everything else pass through it.

Errors

TypeDescription
"unknown option"
Show raw api
{
    "functions": [
        {
            "name": "IsEnabled",
            "desc": "",
            "params": [
                {
                    "name": "part",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "`false` only when `VLUXYAI_SAFE/Enabled` is `false`.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 90,
                "path": "lib/World/SafeAreas.luau"
            }
        },
        {
            "name": "InBox",
            "desc": "Pure.",
            "params": [
                {
                    "name": "cframe",
                    "desc": "The box's CFrame.",
                    "lua_type": "CFrame"
                },
                {
                    "name": "size",
                    "desc": "The box's size.",
                    "lua_type": "Vector3"
                },
                {
                    "name": "point",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [
                {
                    "desc": "`true` when `point` is inside the box, rotation included.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 103,
                "path": "lib/World/SafeAreas.luau"
            }
        },
        {
            "name": "Contains",
            "desc": "The check every layer uses. A floor position counts as inside a room whose part reaches the\nfloor; give a safe part a little depth below the floor if yours sits on it exactly.",
            "params": [
                {
                    "name": "point",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [
                {
                    "desc": "`true` when `point` is inside an enabled safe area.",
                    "lua_type": "boolean"
                },
                {
                    "desc": "That area.",
                    "lua_type": "BasePart?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 132,
                "path": "lib/World/SafeAreas.luau"
            }
        },
        {
            "name": "Refresh",
            "desc": "Makes safe areas solid to the rig group and to no other collision group, including groups\nregistered since [SafeAreas.Setup] (a new group collides with everything by default). Setup\ncalls it, and so does every safe area added later; call it yourself after registering a\ncollision group of your own.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 152,
                "path": "lib/World/SafeAreas.luau"
            }
        },
        {
            "name": "Setup",
            "desc": "Server setup, once. Every tagged part, now and later, gets a `PathfindingModifier` (labelled\n`VLUXYAI_SAFE` while enabled, so [Navmesh] prices it out) and goes in a collision group that only\ncollides with `RigGroup`, solid while enabled and not while off. Players and everything else\npass through it.",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "SafeAreaSetupOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "Destroy it to stop watching the tag.",
                    "lua_type": "Cleaner"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "\"unknown option\"",
                    "desc": ""
                }
            ],
            "source": {
                "line": 175,
                "path": "lib/World/SafeAreas.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "TAG",
            "desc": "",
            "lua_type": "\"VLUXYAI_SAFE\"",
            "source": {
                "line": 66,
                "path": "lib/World/SafeAreas.luau"
            }
        },
        {
            "name": "ENABLED_ATTRIBUTE",
            "desc": "`false` switches an area off. Missing means on.",
            "lua_type": "\"VLUXYAI_SAFE/Enabled\"",
            "source": {
                "line": 74,
                "path": "lib/World/SafeAreas.luau"
            }
        },
        {
            "name": "LABEL",
            "desc": "The `PathfindingModifier` label [SafeAreas.Setup] gives an enabled area, and the cost\n[Navmesh] prices at `math.huge`.",
            "lua_type": "\"VLUXYAI_SAFE\"",
            "source": {
                "line": 83,
                "path": "lib/World/SafeAreas.luau"
            }
        }
    ],
    "types": [
        {
            "name": "SafeAreaSetupOptions",
            "desc": "",
            "fields": [
                {
                    "name": "RigGroup",
                    "lua_type": "string?",
                    "desc": "The collision group your agent rigs are in. A safe area is solid to it and to nothing else. Default [Collision.RIG_GROUP], the group [Collision.AddRig] puts rigs in."
                }
            ],
            "source": {
                "line": 40,
                "path": "lib/World/SafeAreas.luau"
            }
        }
    ],
    "name": "SafeAreas",
    "desc": "Places agents never go. Tag a part `VLUXYAI_SAFE` and it is a safe area for as long as its\n`VLUXYAI_SAFE/Enabled` attribute is not `false`; set the attribute to switch it off and on.\nCall [SafeAreas.Setup] once on the server so the part gets its navmesh modifier and is solid\nto agent rigs. The rest is automatic: [Navmesh] never plans through an enabled area, [Straight]\nnever walks a line across one, [Graph] skips nodes in one when given `Avoid =\nSafeAreas.Contains`, and a player standing in one is left out of\n[Perception.AliveRoots], so no sense targets them.\n\n```lua\nVluxyAI.SafeAreas.Setup({ RigGroup = \"Monsters\" })\n```",
    "source": {
        "line": 61,
        "path": "lib/World/SafeAreas.luau"
    }
}