To implement animations in-game, use scripts. For this tutorial, you’ll add your victory animation into a game using a pre-made script. Once finished, this animation can be used to celebrate a player’s accomplishment, like reaching the end of an obby or finding a secret.
New to Scripting? »
This guide covers step-by-step how to add and modify a script. It assumes some previous knowledge of scripting and isn’t intended to teach these concepts.
For your own game, you may need to make modifications to this script. To better understand scripting, we recommend going through the Code Fundamentals series.
Set up the Project
- To organize all parts that will play the animation, add a folder in Workspace (hover over Workspace and click ) named TouchPartFolder.
Why Add Parts in a Folder? »
The script provided later will play feedback for any parts in this folder that are touched. This makes organizing your game easier than attaching a script onto an individual part.
- In TouchPartFolder, add a part.
- Make sure the part is placed where playing the animation would make sense, such as the end of a level or near an object players collect.
- This first script attaches a
Touched()event to any parts in the TouchPartFolder. Once a player touches any part there, it’ll play an animation.
- The next script triggers animations for a player. In ReplicatedStorage, create a new ModuleScript named PlayerAnimationFeedback. Then, copy and paste the code below.
Previous Improve and Export Next Playing Animations