Time to bring all this work together! Now that you’ve created the beam and particle components, you’ll add in three premade scripts. These scripts manage the tutorial by telling components when to do what. For example, the scripts will create beams for new players and emit particles whenever they interact with goals
Need an Introduction to Scripts? »
Store Beam and Particles
Before adding the scripts, the beam and particles need to be moved to where the scripts will be able to make copies of them as needed.
Naming Matters for the Script
The scripts added later will reference the objects named exactly as in this tutorial. If you’re using your own project, you may need to replace the values within some scripted variables to match your objects.
- In ReplicatedStorage, create a new folder named PlayerTutorial. Move TutorialBeam out of TestPlayer, and into the new folder.
- In ServerStorage, create a folder named TutorialParticles. Move the Burst particle out of TestPlayer into that folder.
- Once the beam and particle emitter are moved, you no longer need the TestPlayer. Delete TestPlayer since the script will work with real players when finished.
Each time players interact with a goal, the tutorial script will need to know so it can update that player’s progress and emit the particle effect. To inform scripts, signals can be sent using events.
- In ReplicatedStorage > PlayerTutorial, create two RemoteEvent objects. Name them NextGoal and TutorialEnd.
Learn More About Events »
Add the Scripts
The three scripts below will look for the particle emitter and beam objects created earlier and manage the tutorial system.
- In ReplicatedStorage > PlayerTutorial > create a new ModuleScript named TutorialManager.
- In ServerScriptService, create a new Script named TutorialParticles.
EMIT_RATEthat determines how many particles spawn during an interaction.
- In StarterPlayer > StarterPlayerScripts, create a new LocalScript named TutorialScript.
- Play the project to test the scripts. Move from booth to booth, using the interact feature to see if code works.
Troubleshooting Tips »
Issue: Particles play when game starts.
Go into ServerStorage > Tutorial Particles > Burst. Check Enabled to be off.
Issue: Warnings in the compiler such as an “infinite yield”.
Because the script is looking for specific objects in certain locations, it’s possible that a part is named incorrectly. Double check that the name and location of each part in game matches the tutorial.
Script Benefits and Limitations »
If you’re using this tutorial system in your experience, keep in mind the following:
- Events such as TutorialEnd can be used to trigger other scripts. For instance, you can award players a special item when this event fires.
- The TutorialParticles script can play multiple particles at once. You can add more particles in ServerStorage/TutorialParticles for more complex effects.
- Player progress in the tutorial is not persistent, meaning you’ll have to code some way of saving that progress. For guidance, see the article: Saving Data.
Previous Using Particles for Actions Next Next Steps