Taking damage or Instant kill on floor if the player is on it.

Hello everyone. I'm stuck on how to make an instant kill or taking damage on the floor if the player is on it.
Example: Player walk on spiked floor, the event of the spikes starts where the spikes pop up from the floor and after that kill the player, but if the player is moving away from the spikes is still alive.
I tried different ways, but when I walk over the spikes it kills me anyway where I am. I tried with 'event touch', 'player touch' but without success. I hope you understand what I'm meaning. Thank you.
when touch: (allow knockout)
damage (full party) HP - 99999 dmg

this will lead to game over if you wish.
For a timed spike trap, one possible setup is to give your spike event two pages:
  1. Trigger: Player Touch, Conditions: (None), commands:
    Code:
    ◆Control Self Switch:A = ON

  2. Trigger: Parallel, Conditions: Self Switch A is ON, commands:
    Code:
    ◆Comment:Spikes pop up after short delay
    ◆Set Movement Route:This Event (Wait)
    :                  :◇Wait:25 frames
    :                  :◇Direction Fix OFF
    :                  :◇Turn Left
    :                  :◇Turn Right
    :                  :◇Turn Up
    :                  :◇Direction Fix ON
    ◆Comment:Check difference between locations of player and this event~
    ◆Control Variables:#0008 Temporary = Map X of Player
    ◆Control Variables:#0008 Temporary -= Map X of This Event
    ◆If:Temporary = 0
      ◆Comment:Same X, now check Y...
      ◆Control Variables:#0008 Temporary = Map Y of Player
      ◆Control Variables:#0008 Temporary -= Map Y of This Event
      ◆If:Temporary = 0
        ◆Comment:Player is standing on spikes! Ouch!
        ◆Play SE:Damage5 (2, 125, 0)
        ◆Flash Screen:(255,0,0,128), 20 frames
        ◆Change HP:Entire Party, - 50 (Allow Knockout)
        ◆Comment:Reset spikes after a short delay
        ◆Set Movement Route:This Event (Wait)
        :                  :◇Wait:10 frames
        :                  :◇Direction Fix OFF
        :                  :◇Turn Right
        :                  :◇Turn Left
        :                  :◇Turn Down
        :                  :◇Direction Fix ON
        ◆Comment:End event here so the spikes continue to activate
        ◆Exit Event Processing
        ◆
      :End
      ◆
    :End
    ◆Comment:If the event gets here, the spikes missed~
    ◆Comment:Reset spikes after a short delay
    ◆Set Movement Route:This Event (Wait)
    :                  :◇Wait:10 frames
    :                  :◇Direction Fix OFF
    :                  :◇Turn Right
    :                  :◇Turn Left
    :                  :◇Turn Down
    :                  :◇Direction Fix ON
    ◆Comment:Return to page 1
    ◆Control Self Switch:A = OFF
For this I used the default floor spikes character from !Other1; it should start in the "hidden" position on both pages. The parallel page needs one variable, for comparing the player and event coordinates. You can reference a character's coordinates via the Control Variables > Game Data > Character option.

Hopefully the comments explain what's going on, but feel free to ask questions if you can't get it working or wanted something different~
Thanks Caethyril this one works, but when the player stops just next to the event (spikes) it can be damaged or killed. Is there a way to fix this?

EDIT: Sorry, my mistake. I've didn't change the correct variable for the coordinates. Now is perfect. Thank you very much 🙂.

Original thread: https://forums.rpgmakerweb.com/threads/taking-damage-or-instant-kill-on-floor-if-the-player-is-on-it.134502/