Answered by
8 years ago Edited 8 years ago
That is pretty simple. You need to use the Touched
event, and bring the animation you have.
Since you will perform camera manipulation along with the animations, a LocalScript
will bring you better results (by eliminating lag)
1. Get and store what you want
First, you need to tell the script where are the instances you need to do that animation:
2. Loading the animation
Once you get the animation, you should load it into the player. Since it is a LocalScript
, you may use the LocalPlayer
property:
1 | local animationTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation) |
3. Listening to the touch event and start the animation!
Every part has a Tocuhed
event that is fired when it is touched by something. You can use it then to trigger your event.
Final script
03 | local animationTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation) |
05 | part.Touched:connect( function (p) |
06 | if game.Players:GetPlayerFromCharacter(p.Parent) = game.Players.LocalPlayer then |
Hope I helped!