Guides › Logic & scripts
A function is a list of commands that runs all at once, a bit like a saved chain of command blocks. In Bedrock add-ons, functions are the easiest way to add game logic: give items, set scores, play effects or run minigame rules.
The Function editor in Addon's Studio lets you write the commands and choose when they run, with no files or folders to manage. You can then hook functions up to items, blocks and mobs.
Make one now in Addon's Studio
Step by step
Add a Function
In your project, tap Add item and choose Function. Give it a name.
Write the commands
Write one command per line, without the /. For example: say Hello from my addon!
Choose when it runs
Pick Only when used, When a player joins, Every few seconds or Every tick.
Use it from items, blocks and mobs
Open an item, block or mob, go to its Actions and pick this function for an event.
Run it yourself
In game, type /function followed by the function's name.
Tips
- Timed and join functions run as each player, so @s is that player.
- Every tick means 20 times a second, so keep tick functions short.
- Use Every few seconds for things that don't need to be instant, like keeping an effect on.
- Item and block actions run as the player, while mob actions run as the mob.
Questions
What's the difference between a function and a script?
A function is a list of commands. A script is JavaScript using the Script API, which can do more but needs coding. Start with functions.
Do I need cheats on?
To type /function in chat, yes. Functions that the add-on runs on its own, like timed, join or action functions, don't need you to type anything.
Can a function run when a mob dies?
Yes. In the mob's Actions, pick the Dies event and choose your function.
Related guides
Try it free
Addon's Studio runs in your browser. No download, no coding.