So I made a animation and I want it to play when someone clicks the character.
Basically I have a ClickDetector named “Activate” in the Character, the characters name is “CopCharacter”, and the animation link is Cop Shooting - Roblox, But the rbxassetid thing is http://www.roblox.com/asset/?id=6409359336.
I want you to click the “CopCharacter” and it plays the animation.
Any help is greatly appreciated!
Hi, @pocvq. I’ll be glad to set you in the right direction. You can achieve this with an AnimationTrack
which is created once you use the :LoadAnimation(Animation)
method on a Humanoid
.
So, given that our CopCharacter is a living Player or NPC (Non-playable Chararcer) with a Humanoid
, then we can load an animation into their humanoid to play.
Here is what some code would look like:
local CopCharacter = workspace.CopCharacter -- need to set the pathway for the CopCharacter
local Animation = Instance.new("Animation", "http://www.roblox.com/asset/?id=6409359336")
local AnimationTrack = CopCharacter.Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
Here is the wiki link for where I got the information for the code from:
Thank you this will help me alot and special thanks for explaining it, it helps me alot to know what things do and mean thank you so much.
1 Like
Of course! Glad to help
Feel free to reach out if you need any more help!
Ok thank you this does help alot.
1 Like