#Why is this not working? on stable

1 messages Β· Page 1 of 1 (latest)

rotund mesa
#

the item does nothing when I interact, does anyone know why? πŸ™ I don't have any error in the content log```Javascript
world.afterEvents.playerInteractWithBlock.subscribe((data) => {
const {block} = data;
const blockState = block.permutation.getState("test:variation");

if(block.typeId === "test:block_1") {
    if(blockState == 0) {
        block.setPermutation(BlockPermutation.resolve(block.typeId, {
            "test:variation": 1
        })),
[...]```
#

typed all ids correctly and made sure that the (block) states work fine so I'm sure I have something wrong in this script

swift stratus
#

should work

rotund mesa
#

then I get this error, no idea why [Scripting][error]-ReferenceError: Native function [Block::setPermutation] does not have required privileges.

#

I mean, when I use beforeEvents then I get that error

rotund mesa
#

thanks!!! :) now it works some how

#

although idk why it sets cardinal_direction trait to its default value when the script is executed

#

I'm just using setPermutation to change that state value, nothing else, why does it change the cardinal_direction?

viscid rose
#

Because you create a new permutation where all states are reset to the default value if you did not specify them. In this case you need to do this: ```js
block.setPermutation(block.permutation.withState("test:variation", 1))

#

Here you change 1 property, and do not create all the properties again as in your previous code

rotund mesa
#

oh nice, I see

#

thank you so much, really appreciated