An undefined hat block is a block generated by an error. It can not be connected with any other block, and doesn't have any function. Some Scratchers call it a Hat Block but it is actually a combination of both a hat and Cap Block. It does not have an input. It is the only red block in Scratch 3.0. Unlike other blocks, it does not have an outline. It cannot be commented on, and trying to comment on this block will cause the block to follow the mouse. Going to a different sprite while it's following the mouse will cause the block to disappear, and attempting to go back to the original sprite causes the block to become immobile. Going to the Costumes or Sound Tab and returning to the code will crash the project. This block cannot be found in the blocks palette, so it requires the below methods to make them.
One of the only ways of generating this block is to edit the project JSON file. The steps are as follows:
- Make a new project and drag a block.
- Save the project to your computer and rename the .sb3 to .zip.
- Open the .json file, locate the block, and rename it to something that doesn't exist.
- Change the file back into .sb3 and load it from your computer.
- The project should now have the block.
This method is simple, just backpack a undefined hat block from other's projects.
Trying to create a custom block with a name containing a control character, such as the backspace character or a NAK (Negative Acknowledge) character, also creates an undefined block.
NAK can be copied from (works in most of the browsers): First, go to [[scratch:search/projects?q=%15]]. Then copy the invisible character from the search bar. Paste it onto a custom block (on an empty project) and the red hacked block will appear. However, putting it into an existing project will make it glitch, causing the whole project to disappear. Its code becomes hidden, but it works. Other control characters such as %14 (device control 4) also work, and creates the general red hat block.
The control characters' names can be found when highlighting it.