3

Datapack Not working... Please help!

Penaple01 10/8/22 4:00 pm history
100
11/7/2022 2:10 pm
I want to have a datapack that will run a command when you are stepping on a block, but only once; here is what I wrote:

execute as @a[​scores={noreptest=0}] at @s if block ~ ~-1 ~ minecraft:ancient_debris run scoreboard players set @s noreptest 1
execute as @a[​scores={noreptest=1}] run say hi
execute as @a at @s unless block ~ ~-1 ~ minecraft:ancient_debris run scoreboard players reset @a[​scores={noreptest=1}] noreptest

This is not working, and noreptest never gets set to one. (The player does start with noreptest = 0, I made sure of this). However, when I change the code just slightly:

execute as @a at @s if block ~ ~-1 ~ minecraft:ancient_debris run scoreboard players set @s noreptest 1
execute as @a[​scores={noreptest=1}] run say hi
execute as @a at @s unless block ~ ~-1 ~ minecraft:ancient_debris run scoreboard players reset @a[​scores={noreptest=1}] noreptest

Then it works, but it runs the command every tick, not just once. Any help would be extremely appreciated thank you. This is my first time writing any datapack, and I know its simple but I want it to work.
Posted by
Penaple01
Level 1 : New Miner
0

  Have something to say?

JoinSign in

1

Thorn_123
11/07/2022 2:10 pm
Level 13 : Journeyman Scribe
history
So, are you trying to run a command when a player steps on a specific block, but only do it once (every time the player steps somewhere else and again at the block)?

If so, here's how to do it:

You don't need to use scoreboards at all, tags are enough.


Just put this in the tick/loop function and modify it for your needs: (Keep the order!)


execute as @a[tag=!step] at @s if block ~ ~-1 ~ ancient_debris run say your commmandexecute as @a[tag=!step] at @s if block ~ ~-1 ~ ancient_debris run tag @s add stepexecute as @a[tag=step] at @s unless block ~ ~-1 ~ ancient_debris run tag @s remove step
2

Welcome