Updated:

1. Pitfall

# repeat, always active
execute if entity @a[x=10,y=64,z=10,dx=2,dy=1,dz=2] run fill 10 63 10 12 60 12 minecraft:air

Step on the 3 by 3 floor at Y 63 and four layers vanish. See area detection.

2. Arrow trap

execute if entity @a[x=20,y=64,z=0,dx=0,dy=1,dz=6] run summon minecraft:arrow 17 65 3 {Motion:[1.5d,0.0d,0.0d],pickup:0b}

Entering the corridor fires arrows east from a hole in the wall. pickup:0b stops players from collecting them.

3. Lightning zone

execute at @a[x=30,y=64,z=0,dx=4,dy=2,dz=4] run summon minecraft:lightning_bolt ~ ~ ~

See the lightning command.

4. Poison floor

execute as @a at @s if block ~ ~-1 ~ minecraft:crimson_nylium run effect give @s minecraft:poison 2 0

Works anywhere you place crimson nylium.

5. Fire once and reset

execute as @a[x=30,y=64,z=0,dx=4,dy=2,dz=4,tag=!trapped] at @s run summon minecraft:lightning_bolt ~ ~ ~
tag @a[x=30,y=64,z=0,dx=4,dy=2,dz=4] add trapped
fill 10 63 10 12 63 12 minecraft:stone

The tag limits the strike to once per player; the last line restores the pitfall. Combine traps with an escape room.

Troubleshooting

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.