Back to Guides & WikiDec 2025
Scripting Basics with Code Blocks API
Learn how to use the Code Blocks API to make interactive worlds.
Loading Guide...
Code Blocks in Bloxd.io allow you to run JavaScript code when a player interacts with them. This enables you to create minigames, teleporters, shops, and complex mechanisms.
Writing code directly in the small in-game window is difficult. BloxdForge provides a professional development environment (IDE) for scripts.
Stuck on a script? Open the AI panel and ask: "Write a script that gives the player speed when they click this block." The AI understands the specific Bloxd API functions.
The editor automatically checks for errors. If you use a function that doesn't exist (e.g., api.kill() instead of api.killLifeform()), it will underline it in yellow and suggest the fix.
Here are the most common functions you will use in your scripts.
/* Launch player into the air */
const velocity = { x: 0, y: 25, z: 0 };
api.setVelocity(myId, velocity.x, velocity.y, velocity.z);
/* Teleport player */
api.setPosition(myId, 100, 50, 100);/* Give items (ID, ItemName, Amount) */
api.giveItem(myId, "diamond", 5);
/* Check if player has item */
if (api.hasItem(myId, "gold_ingot")) {
api.sendMessage(myId, "Rich!");
}api.log("Message"); to print to the browser console (F12).api.sendMessage(myId, "Debug info"); to print variable values directly to your chat.