WaitForChild() Helps Avoid Run-time Errors
Because scripts in Roblox run at different times, it’s possible that a player’s head might not be created yet. To avoid errors, like trying to find a part that doesn’t exist, the script uses
WaitForChild() to get the head part attached to the player’s character instead of using the dot operator, like
- Add a wait function and destroy the particles after one second.
- Playtest the game and make sure particles briefly follow the player after touching each color.
- Make when creating a new instance that ParticleEmitter is spelled exactly as shown and inside quotations.
- When parenting the particles, make sure to use
WaitForChild()with no spaces between.
Finished Project Sample
Download the finished project here.