Minecraft Command Troubles

minecraft-bedrock-editionminecraft-commands

I've been playing the Bedrock version of Minecraft on Switch and I'm trying to get a lever that can only be placed on a gold block this is what I entered in the command block:

/give @p lever 1 0 {CanPlaceOn:["Block_of_Gold"]}

After that it just says

Line 1 Column 2 Missing '}' or object member name

Can anyone tell me what I'm doing wrong?

Best Answer

As Fabian pointed out, the name for “Block of Gold” isn’t Block_of_Gold, it’s gold_block. Bedrock Edition uses JSON format, not NBT, so the command would be:

/give @p lever 1 0 {"can_place_on":{"blocks":["gold_block"]}}

See this post for more information on using "can_place_on".

Source: Block of Gold on Minecraft Gamepedia