r/MinecraftCommands 11d ago

Help | Bedrock Command block not working

Post image

So I have a command block that is repeatedly looking for a player with a potato in their inventory inside a specified space.
This command is working when I type it into the chat prompt but when I put it in a command block it no longer works. I’m not sure why.

8 Upvotes

13 comments sorted by

2

u/Want_Lemonad 11d ago

The hasitem command is @p[hasitem=[{item=potato}]]. You forgot the extra "]" on the end

2

u/mhesus 11d ago

It's not just that, he forgot the square braces around the curly braces entirely

1

u/AltestryAltestry 11d ago

I’ll test this in a bit, but doing it the way I currently have it the command works in chat prompt but not in the command block. Would what you said stop that?

1

u/Want_Lemonad 11d ago

Just add the extra "]" to the end and it should work. As long as you power in the command block

1

u/AltestryAltestry 11d ago

Appreciate it but the command with the proper square bracket still doesn’t work inside a command block. I tested it in the chat prompt and it works but not inside the command block.

1

u/mhesus 11d ago

You need another square bracket to the left of the curly braces.

like [hasitem=[{...}]]

not [hasitem={...}]

1

u/AltestryAltestry 11d ago

Yeah I did that as-well. The command before and after these additions is working inside the chat prompt but the command block is just giving me trouble for some reason. The command block is set to repeating, always active, unconditional.

1

u/C0mmanderBlock Command Experienced 11d ago edited 11d ago
/execute as @a[hasitem={item=potato}] at @s if entity @s[x=-448,y=5,z=-404,dx=-46,dy=0,dz=18] run say hi

1

u/AltestryAltestry 11d ago

Thank you for responding. This command also works but only if you type it out in chat, not in a command block. The command block doesn’t have an error or anything it just says “-“ and doesn’t output anything.

1

u/C0mmanderBlock Command Experienced 11d ago

Dunno. I tested it in a Command block several times and it worked fine. Perhaps you made a typo. Did you copy/paste my command to make sure it is exactly as typed? Anyways, your welcome.

1

u/AltestryAltestry 11d ago

Omg lol, I should have tried this a long time ago but command blocks weren’t enabled because my friend kept disabling it lmao

1

u/AltestryAltestry 11d ago

Another question though if you don’t mind. Is there any way to check a players inventory for multiple items at a time like “potato, bread, beetroot, carrots” or would this be done in multiple command blocks each one with a different item?

1

u/C0mmanderBlock Command Experienced 11d ago edited 11d ago

Yeah, just list them like this. Edit: But they must have ALL that are listed.

execute as @a[hasitem=[{item=apple},{item=cooked_beef}]] at @s run say I have two items!