Throws an error, if the format printing setting is enabled then it will format the message with repr. 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.
Exactly the same as Roblox's require function, but is blocked from people in place 1 (outside of VIP servers) that don't have place 1 require permissions. This is because this function can very easily escape the sandbox.
If you want to use mesh parts or not have to use model to script in place 1, then check out LoadAssets.
LoadLibrary
LoadLibrary(library: string): any
A reimplementation of Roblox's LoadLibrary feature which was removed.
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.
Has almost the exact same functionality as require. But can only have asset id's as the target, and does some security checks to prevent people from running untrusted code outside the sandbox. This is used to load user made assets into the game (even meshparts).
First of all you need to get the Model from Roblox here, and then add it in studio. After that you can insert in all assets that you want to be able to use ingame. And then publish the ModuleScript (remember to enable "Distribute on Marketplace"), then copy the asset id.
(Remember that modifying the ModuleScript's source or adding any blocked instances will cause it to be blocked in-game.)
After that you can call LoadAssets() with the asset id you copied and then use :Get() with the name of the asset you want.
Blocked instances
Script
LocalScript
ModuleScript
CoreScript
PackageLink
AdPortal
FloorWire
SkateboardPlatform
DynamicImage (might change)
Examples
Loads a noob mesh into the game near spawn.
local Assets = LoadAssets(13220242943)
local NoobMesh = Assets:Get("Noob")
NoobMesh.Parent = workspace
Loads a mesh of Roblox and Builderman into the game near the spawn.
local Assets = LoadAssets(13242794521)
for _, Asset in ipairs(Assets:GetArray()) do
Asset.Parent = workspace
end
Prints a list of drinks to the player's output, and allows them to get them by saying ",drink " followed by the drink name.
local Assets = LoadAssets(13242863830)
local function GetList()
printf("Say ',drinklist' to see this again.")
printf("Say ',drink ' followed by one of the names listed below to get it:")
for _, Name in ipairs(Assets:GetNames()) do
print(Name)
end
end
local function GetDrink(Name)
if not Assets:Exists(Name) then
return warnf("Invalid drink name, say ',drinklist' to get a list of drinks.")
end
local Tool = Assets:Get(Name)
local Handle = Tool:WaitForChild("Handle")
Tool.Parent = owner:FindFirstChildOfClass("Backpack")
Tool.Equipped:Connect(function()
Handle.OpenSound:Play()
end)
local Enabled = true
Tool.Activated:Connect(function()
if not Enabled then
return
end
Enabled = false
Tool.GripForward = Vector3.new(0,-.759,-.651)
Tool.GripPos = Vector3.new(1.5,-.5,.3)
Tool.GripRight = Vector3.new(1,0,0)
Tool.GripUp = Vector3.new(0,.651,-.759)
Handle.DrinkSound:Play()
task.wait(3)
Tool.GripForward = Vector3.new(-.976,0,-0.217)
Tool.GripPos = Vector3.new(0.03,0,0)
Tool.GripRight = Vector3.new(.217,0,-.976)
Tool.GripUp = Vector3.new(0,1,0)
Enabled = true
end)
end
owner.Chatted:Connect(function(message)
if string.sub(message, 1, 3) == "/e " then
message = string.sub(message, 4)
end
if string.sub(message, 1, 10) == ",drinklist" then
GetList()
elseif string.sub(message, 1, 7) == ",drink " then
GetDrink(string.sub(message, 8))
end
end)
GetList()
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)