Block guide
Basics
Before learning the blocks, here are the 2 key concepts for coding in Roblox Studio.
Relationships
First, we need to know how everything finds everything else. To make stuff happen, scripts need to know who to ask and where to find them. In a Model with a bunch of Parts, the Model is called the parent and the Parts are its children. The me reporter, used in almost every script, is a shortcut to script.Parent. With it, we form sentences like "when me is touched" or "put Sound in me" with our blocks.
Properties
Once we find what we need, we can read or change its properties. To move a Part, we can build "set Position of Part" from blocks. Some properties, like someone's Roblox subscription, cannot be changed by our script. Instead of setting, coders can read these properties to decide how their script should react. For example, we can reward bonuses to subscribed users even though we can't change the subscription itself.
me
property of targetCore block
Congrats, that's all the programming experience you need to code with ABC!
Also, I've added a next to what I call the "core" blocks. Core blocks translate directly to Luau, and everything else uses core blocks behind-the-scenes. So technically, the more core blocks you use, the closer your code will look to actual Luau, which is awesome. In the docs, there are only 31 core blocks in the full 70 block palette. If you're skimming the docs for the first time, those are the ones to start with. You've already learned two!
Events
Event blocks connect game events to code. You can use call method() on target to disconnect.
when thing is touched hit
Runs when
thingis touched and provides what's touched ashit.In Kill Brick
when joins player
when leaves player
Runs when a player joins or leaves the game and provides
player.In Announcement and Leaderboard
when character of player spawns character
Runs when a character spawns from
playerand provides thecharactermodel.when game closes
Runs when the server is shut down.
In Leaderboard
every number seconds
Runs every
numberseconds.In Dropper and Leaderboard
each frame delta
Runs every frame and provides
deltaas the amount of time that passed since the last frame, which is around 1/60 or 0.016 seconds.at the same timeCore block
Runs when the game starts. Blocks here run at the same time as everything else, as if in their own script. This is usually used when you have timers and do not want to delay the rest of the program.
when property of target changesCore block
when the name attribute of target changesCore block
Runs when
propertyornameoftargetchanges. To see the new value, use property of target or get attribute name of thing as n.when event receivedCore block
Runs when
eventis received. Blocks such as when thing is touched and when player joins use this behind-the-scenes.In Steal
when remote fired from side
Runs when
remote, a RemoteEvent, is sent fromside. Use this when the Server and Client need to communicate. To fire the event, see fire remote to side.
Control
Control blocks change the sequence of code through delays, branching paths, and repetitions.
wait number secondsCore block
wait until event
Pauses the script for
numberseconds, or untileventhappens. If you need multiple, separate timers, create a separate script for each or put this inside of at the same time.In Announcement
if condition then
conditionCore block
if condition then … elseCore block
Runs the blocks inside if
conditionis true. You can use the else version if you also need something to happen when it's false.In Kill Brick, RNG and Tween
for first to last iCore block
Runs the blocks inside counting from the
firstnumber to thelast. It providesias the current number.In RNG
for each in list _ itemCore block
Runs the blocks inside once for every item in
list(also called a "table") and providesitemas the current item._is the current spot in the table or key in a dictionary. Its default is an underscore because it's often unused.while conditionCore block
Runs the blocks inside while
conditionis true. To avoid freezing the game, use a delay in your loops with wait number seconds. For tracking a condition, listener blocks are often the better choice, such as when property of target changes, when the name attribute of target changes, or when event received.for each player
Runs the blocks inside once for every player and provides
playeras the current player.In Leaderboard
breakCore block
Breaks out of a loop.
continueCore block
Skips to the next turn of the loop.
try … as success result
Runs the blocks inside and protects the rest of the script from any errors inside.
successtells you if it worked, andresulttells you what your blocks returned or an error message. For example, load key from store as value and save value under key in store have this block bundled in to prevent failed calls from stopping your script.
Actions
Action blocks are common verbs that can be done to Instances. To keep the palette small, not all verbs have their own block. You can use call method() on target to access other actions.
create Instance as thing
new AnyCore block
Creates a new
Instancein the data asthing. To use it in the game, add put thing in parent. You can also create using the "new" reporter, which is not limited to instances. It makesAny, including datatypes like vectors and colors.clone thing as copy
Clones a
thingand puts it in the data ascopy. To use it in the game, add put thing in parent.In Dropper
put thing in parent
Moves
thingtoparent. Used to put an Instance you created or cloned into the game.In Dropper, Leaderboard and Steal
weld part0 to part1 with weld
Sticks two parts,
part0andpart1, together with aweld. To stick two Models together, you can find both of theirPrimaryPartand use those as the two parts.In Steal
destroy thing
destroy thing after number seconds
Removes
thingfrom the game, right away or afternumberseconds. The timed block uses theDebrisservice.move thing by offset
Moves
thingbyoffset. For each axis, define a distance to move.rotate thing by angle
Rotates
thingbyangle. For each axis, define the degrees to rotate.teleport thing to place
Teleports
thingto aplaceCFrame. To teleport to an object, you need its pivot. This can be found with call method() on target.tween property of thing to value using infoCore block
Changes a
propertyvalue tovaluesmoothly over time. If you need the script to pause until the tween is finished, add wait until event after. Createinfowith new Any, allowing you to fully customize the animation.In Tween
call method() on target
call method() on targetCore block
Tells the
targetobject to do one of its built-in actions, known as amethod. Blocks such as create Instance as thing and destroy thing use this behind-the-scenes. Use the reporter version instead when you care about what the method call gives back, such as storing it using local n to value.In Day/Night, Kill Brick and Announcement
fire remote to side
Sends a message through
remote, a RemoteEvent, toside. TheRemoteEventshould be somewhere that both the Server and Client can access, such asReplicatedStorage. To receive the message this block sent, use when remote fired from side.
Variables
Variable blocks create, set, or change variables and properties.
local n to valueCore block
Creates a new variable called
nset tovalue. "local" variables can be used in the body of code they're defined in. Any block that ends with "as ..." uses this block behind-the-scenes.In Day/Night, Announcement and Tween
set target to valueCore block
change target by amount
Changes the
targetvariable or property to avalueor by anamount. Negative values can also be used, allowing you to subtract.In Day/Night, Announcement and Tween
random first to last as n
Creates a new variable called
nas a random number betweenfirstandlast.In RNG
add item to list
list itemsCore block
remove item index from list
item index of listCore block
Adds an
itemto the end of alist, or removes the value at theindexspot. Before editing a list, you should create it using the "list" reporter. Avoid removing items inside for each in list, as some items will be skipped.get attribute name of thing as n
Reads the
nameattribute ofthingand stores it asn. You can find attributes in the Properties window.set attribute name of thing to value
change attribute name of thing by amount
Changes the
nameattribute ofthingto avalueor by anamount. Negative values can also be used, allowing you to subtract.
Lookups
Lookup blocks find instances and information in the Explorer.
find name in parent as n
find name in parent
Finds
nameinparentif it exists and stores it asn. You can use if condition then to check if it was found.In Kill Brick, Dropper and Leaderboard
wait for name in parent as n
Finds
nameinparentif it exists and stores it asn. If it's not there when this block runs, the script waits. This is often used to access things that load in after the game. If you need multiple, separate delays, create a new script for each or put this inside of at the same time.In Announcement
get children from parent as list
Creates a list of every Instance in
parentand stores it aslist, which you can loop through using for each in list.get from character as player
Finds the Player from a
charactermodel.get service name as n
service PlayersCore block
Loads a built-in service called
nameasn.In Day/Night, Announcement and RNG
require module as n
Loads a ModuleScript as
nso that you can use its variables and call its functions.In RNG
open data store name as store
Opens a DataStore called
namefor saving and loading user data, and returnsstore. A common issue with this block is that games cannot access data stores, so you should first enable them by publishing your game and following these steps:- Open Experience Settings
- Navigate to Security
- Enable the Enable Studio Access to API Services toggle
- Click Save
In Leaderboard
load key from store as value
save value under key in store
Loads or saves
valuefor akeyin thestore. Open the data store with open data store name as store before using.In Leaderboard
Functions
Functions are your own blocks that you can use anywhere. Define function name(inputs) to start. inputs let your block work with different values. For example, number is the input in wait number seconds. You can use return value to send something back. run name(inputs) runs the block, but make sure to define the block before trying to run it.
function name(inputs)Core block
return valueCore block
run name(inputs)
run name(inputs)Core block
In Announcement, RNG and Leaderboard
Debug
Debugging does not change what a script does, but it does help you and others follow the logic. When building a script, learn by using a comment to explain sections or leave questions. If something goes wrong, add print message to tell you a line was reached or track variables at each stage of the script. These messages appear in the game's output, not to the players.
comment
print messageCore block
Math
Math blocks cover most of the math library, including arithmetic, conditions, and comparisons. function of a handles functions that use one number, such as rounding and trigonometry. Some functions need more, like finding the maximum of two numbers. Use run name(inputs) for these. To keep things concise, constants are not provided by blocks, but you can write the Luau directly into any slot, such as math.pi or math.e.
a + b
function of aCore block