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 thing is touched and provides what's touched as hit.

      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 player and provides the character model.

    • when game closes

      Runs when the server is shut down.

      In Leaderboard

    • every number seconds

      Runs every number seconds.

      In Dropper and Leaderboard

    • each frame delta

      Runs every frame and provides delta as the amount of time that passed since the last frame, which is around 1/60 or 0.016 seconds.

      In Day/Night and Tween

    • 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 property or name of target changes. To see the new value, use property of target or get attribute name of thing as n.

    • when event receivedCore block

      Runs when event is 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 from side. 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 number seconds, or until event happens. 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 condition is 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 first number to the last. It provides i as 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 provides item as 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.

      In RNG and Steal

    • while conditionCore block

      Runs the blocks inside while condition is 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 player as 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. success tells you if it worked, and result tells 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 Instance in the data as thing. 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 makes Any, including datatypes like vectors and colors.

      In Dropper, Tween and Steal

    • clone thing as copy

      Clones a thing and puts it in the data as copy. To use it in the game, add put thing in parent.

      In Dropper

    • put thing in parent

      Moves thing to parent. 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, part0 and part1, together with a weld. To stick two Models together, you can find both of their PrimaryPart and use those as the two parts.

      In Steal

    • destroy thing

      destroy thing after number seconds

      Removes thing from the game, right away or after number seconds. The timed block uses the Debris service.

      In Dropper and Steal

    • move thing by offset

      Moves thing by offset. For each axis, define a distance to move.

    • rotate thing by angle

      Rotates thing by angle. For each axis, define the degrees to rotate.

    • teleport thing to place

      Teleports thing to a place CFrame. To teleport to an object, you need its pivot. This can be found with call method() on target.

      In Dropper and Steal

    • tween property of thing to value using infoCore block

      Changes a property value to value smoothly over time. If you need the script to pause until the tween is finished, add wait until event after. Create info with new Any, allowing you to fully customize the animation.

      In Tween

    • call method() on target

      call method() on targetCore block

      Tells the target object to do one of its built-in actions, known as a method. 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, to side. The RemoteEvent should be somewhere that both the Server and Client can access, such as ReplicatedStorage. 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 n set to value. "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 target variable or property to a value or by an amount. 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 n as a random number between first and last.

      In RNG

    • add item to list

      list itemsCore block

      remove item index from list

      item index of listCore block

      Adds an item to the end of a list, or removes the value at the index spot. 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.

      In RNG and Steal

    • get attribute name of thing as n

      Reads the name attribute of thing and stores it as n. You can find attributes in the Properties window.

    • set attribute name of thing to value

      change attribute name of thing by amount

      Changes the name attribute of thing to a value or by an amount. 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 name in parent if it exists and stores it as n. 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 name in parent if it exists and stores it as n. 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 parent and stores it as list, which you can loop through using for each in list.

    • get from character as player

      Finds the Player from a character model.

    • get service name as n

      service PlayersCore block

      Loads a built-in service called name as n.

      In Day/Night, Announcement and RNG

    • require module as n

      Loads a ModuleScript as n so that you can use its variables and call its functions.

      In RNG

    • open data store name as store

      Opens a DataStore called name for saving and loading user data, and returns store. 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:

      1. Open Experience Settings
      2. Navigate to Security
      3. Enable the Enable Studio Access to API Services toggle
      4. Click Save

      In Leaderboard

    • load key from store as value

      save value under key in store

      Loads or saves value for a key in the store. 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