How to toggle (on/off) potion effect when a player hits a keybind

Started by tryunt on

Topic category: Help with modding (Java Edition)

Last seen on 03:47, 31. Mar 2022
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to toggle (on/off) potion effect when a player hits a keybind

Hello, I am looking for help with my superhero mod!

I want to make a shazam set and want it to be when a player hits a keybind (example "k") it will strike them with lighting and give them certain potion effects.

Any help, examples or downloads would be fantastic.

Thank you!

Last seen on 17:20, 17. Mar 2024
Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The simplest way is to make…
Sun, 05/09/2021 - 09:50

The simplest way is to make a variable, and when keybind is pressed,:

If [variable] = 0 (default)

 strike the player with lightning

 set variable to 1

Else (if [variable] = 1)

 set variable to 0

 

Then make a procedure on player tick:

When Variable = 1 (means when the keybind was toggled on)

 Apply potion effect

Last seen on 03:47, 31. Mar 2022
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi, Can you please send a…
Sun, 05/09/2021 - 10:49

Hi, Can you please send a visual of the code if you can!

Thanks!