Testing for a Specific time
I'm trying to run a command block that will run at a certain time.
I feel like there's an easy way to do this but I cannot find out how. I'm trying to avoid a Daylight Sensor and would rather the command able to run once it hits nighttime. Is there any default time stat?
Let's say I want this to run every time night falls :
/say Hello it's now nighttime.
Posted Jan 10, 2021, 10:01 PM UTC
I believe the command you are looking for is
/time query daytimeThis will give you the current time in your world, however if you want to use it you would need to set up a scoreboard.Ex. In two sets of command blocks
First Command Block (Impulse, Unconditional, Needs Redstone)
/scoreboard objectives add TimeObjective dummy2nd Command Block (Chain, Unconditional, Always Active)
/scoreboard players add CurrentTime TimeObjective
First Command Block (Repeat, Unconditional, Always Active)
/execute store result score CurrentTime TimeObjective run time query daytime2nd Command Block (Chain, Unconditional, Always Active)
/execute if score CurrentTime TimeObjective matches 13000 run say It's Night Time!Ahhhhhh thank you. I figured I could use the scoreboard and objectives, I just did not know about the /time query daytime.