Lua Sandbox
  • Welcome
  • Script API
    • Script
      • Variables
      • Functions
    • LocalScript
      • Variables
      • Functions
Powered by GitBook
On this page
  • print
  • warn
  • error
  • printf
  • warnf
  • printidentity
  • require
  • loadstring
  • LoadLibrary
  • NewScript
  • NS
  • NewLocalScript
  • NLS
  1. Script API
  2. LocalScript

Functions

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

PreviousVariables

Last updated 1 year ago

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

print(...: any): void

Prints into the script builder output instead of the Roblox one. If the format printing setting is enabled then it will format the message with .

warn(...: any): void

Warns into the script builder output instead of the Roblox one. If the format printing setting is enabled then it will format the message with .

error(message: any, level: number?): void

Throws an error, if the format printing setting is enabled then it will format the message with . Script errors are automatically caught by the script builder and outputted into your output.

printf

printf(...: any): void

Prints into the script builder output with richtext enabled, ignoring the format printing setting. Useful if you want to print information to the user into the output.

warnf

warnf(...: any): void

Warns into the script builder output with richtext enabled, ignoring the format printing setting. Useful if you want to warn information to the user into the output.

printidentity(prefix: string?): void

This is a deprecated Roblox function, and should not be used in new work. It's just added for compatibility.

require(): never

This function is disabled on client.

loadstring(contents: string, chunkname: string?): (((...) -> any)?, string?)

LoadLibrary

LoadLibrary(library: string): any
List of libraries
  • RbxGui

  • RbxStamper

  • RbxUtility

This is a removed Roblox function, and should not be used in new work. It's just added for compatibility.

NewScript

NewScript(source: string, parent: Instance?, ...any): Script
Examples

Creates a new script in workspace that prints "Hello World! I'm in " followed by its full name.

NewScript([[
printf("Hello World! I'm in", script:GetFullName())
]])

Creates a new script in workspace, and prints the 3 values it's given.

NewScript([[
local var1, var2, var3 = ...
printf("var1:", var1)
printf("var2:", var2)
printf("var3:", var3)
]], workspace, "Hello I'm a string", Instance.new("Part", workspace), {"Tables work too!"})

NS

NewLocalScript

NewLocalScript(source: string, parent: Instance?, ...any): LocalScript
Examples

Creates a new local script in your player gui that prints "Hello World! I'm in " follwed by its full name.

NewLocalScript([[
printf("Hello World! I'm in", script:GetFullName())
]])

Creates a new local script in your PlayerGui, and prints the 3 values it's given.

NewLocalScript([[
local var1, var2, var3 = ...
printf("var1:", var1)
printf("var2:", var2)
printf("var3:", var3)
]], nil, "Hello I'm a string", Instance.new("Part", workspace), {"Tables work too!"})
-- Pass nil as the parent if you want it to go to the default location.

Creates a new local script in your player gui to send your key inputs to the server.

local Remote = Instance.new("RemoteEvent")
Remote.Name = "Input"
Remote.Parent = script

NewLocalScript([[
local UserInputService = game:GetService("UserInputService")
local Remote = ...

UserInputService.InputBegan:Connect(function(Input)
    if UserInputService:GetFocusedTextBox() ~= nil then -- Don't send if typing.
        return
    end
    
    if Input.UserInputType ~= Enum.UserInputType.Keyboard then
        return
    end
    
    Remote:FireServer(Input.KeyCode)
end)
]], nil, Remote)
-- Parents the LocalScript to the default location and gives it the RemoteEvent.

Remote.OnServerEvent:Connect(function(Player, KeyCode)
    if Player ~= owner then -- We don't want other players spoofing!
        return
    end
    
    if typeof(KeyCode) ~= "EnumItem" then
        return
    end
    
    print(KeyCode.Name) -- Print the keycode's name.
end)

NLS

Exactly like on Roblox but will always print identity 2, and outputs into the script builder output.

A reimplementation of Roblox's function on client.

A reimplementation of Roblox's LoadLibrary feature which was .

Creates and returns a new with the specified source under the specified parent, with optional run arguments.

If no parent argument is specified then it will default to .

Alias for .

Creates and returns a new with the specified source under the specified parent, with optional run arguments.

If no parent argument is specified then it will default to the script 's .

Alias for .

print
repr
warn
repr
error
repr
printidentity
printidentity
require
loadstring
loadstring
removed
Script
Workspace
NewScript
LocalScript
owner
PlayerGui
NewLocalScript