Lightning Strike Spell

Step 1
In this lesson you will use what you've learned to add a spell that causes a lightning strike at the target location

It is recommended that you complete The Wand, the Midas Touch, and the setSpell() Function lessons before attempting this challenge unless you have prior experience with custom items, the PlayerInteract event, and exporting functions.

Step 2
CHALLENGE: Add a new item based on the Magic Wand that has the spell set to "Lightning Strike"

NOTE: You do not need a crafting recipe for this wand since we will be using the setSpell() function to give it to the player.

Step 3
CHALLENGE: Add "Lightning Strike" to your setSpell() function

You should be able to use the command /js setSpell("Lightning Strike") to place the wand you made in the previous step in your hand.

Step 4
CHALLENGE: Add code to your onPlayerInteract function that allows you to cast the lightning spell
  1. Check the action the player performed
  2. Check the item in the player's hand
  3. Use world.strikeLightning(location); to cause a lightning strike at location
Check Your Work
Step 5
Make sure everything is working properly

Once you have successfully completed this challenge try to think of another spell you would like to add that would use the PlayerInteract event in a similar way.

Lightning Strike Spell Info


MVCode Clubs

Created By

Mvcc logo new aaron


Wand World

Access Level


For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach