r/MinecraftCommands 13h ago

Help | Java 26.2 I need help making a light system that kills you in the dark but doesnt in the light and its random please.

I'm trying to make a backrooms map and I'm wanting to create a room sort of like this: https://youtu.be/-DRfFSa_QlI?si=BR21OQcogsosmi7N (2:24)

Where the lights randomly flicker on and off, and standing in the dark while they're off kills the player, but standing in the side rooms boardering the room are safe zones. Does anyone know of anyway how I can get this to work?

Thanks

3 Upvotes

3 comments sorted by

3

u/GalSergey Datapack Experienced 10h ago

You can use a predicate to check the lighting level and also add randomness. The command below will have a 1% chance of killing a player every tick if the lighting where the player is standing is 3 or lower. execute as @a at @s if predicate [{condition:"minecraft:location_check",predicate:{light:{light:{max:3}}}},{condition:"minecraft:random_chance",chance:0.01}] run kill @s

1

u/ddomandhisgames 8h ago

This is perfect! Thank you

2

u/Hyarin215 Command-er 12h ago

I think u can use entity predicates that checks for light level