Lua Sandbox
  • Welcome
  • Script API
    • Script
      • Variables
      • Functions
    • LocalScript
      • Variables
      • Functions
Powered by GitBook
On this page
  • _G
  • shared
  • _VERSION
  • owner
  1. Script API
  2. LocalScript

Variables

This page lists all the global variables that you can use with localscripts in the script builder.

Any global variable that are not listed here that is otherwise normally a part of Roblox should keep their vanilla behavior.

_G

The sandbox sets _G to a table that already has a set metatable, and is only shared between sandboxed scripts.

shared

The sandbox sets shared to a table that already has a set metatable, and is only shared between sandboxed scripts.

_VERSION

On localscripts this is set to "Lua 5.1", because they only have Lua 5.1 syntax support. This doesn't mean they can't use newer Roblox features such as Signal:Once().

owner

A refrence to the Player running the script. Same as LocalPlayer.

Examples

Sets the walkspeed of the player running the script to 32.

local Character = owner.Character
if Character then
    local Humanoid = Character:FindFirstChildOfClass("Humanoid")
    if Humanoid then
        Humanoid.WalkSpeed = 32
    end
end

Kills the player running the script with :BreakJoints() if they have a character.

local Character = owner.Character
if Character then
    Character:BreakJoints()
end
PreviousLocalScriptNextFunctions

Last updated 1 year ago