What I want to achieve
I want to be able to make a system that, once the player uses a tool, an animation will play. This is a system you see in a lot of dance games and athletic games where you use a tool to preform actions.
Example from a friend
The Issue
The animation won’t play whenever I click on the screen.
Solutions I have tried
Looking up tutorials on Youtube. I’ve tried following a tutorial by the name of “RoScripter” but it didn’t seem to work and the animation did nothing. Yes, I have looked at the DevForum also, but I’ve searched and nothing appears to the problem I’m trying to solve. If there was one that explains the problem I missed, drop the topic below in the replies.
Script
The following script is what I used:
local Tool = script.Parent
local Animation = Tool.Animation
local Tool = script.Parent
local Animation = Tool.Animation
Tool.Activated:Connect(function()
local Character = Tool.Parent
local Humanoid = Character.Humanoid
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
Tool.Unequipped:Connect(function()
AnimationTrack:Stop()
end)
end)
Step by Step of what I did
Firstly, I went to the Rig Builder (in plugins) and imported an R6 blocky rig (as my game is in r6). Then I went to Animation Editor (Also in plugins) and made a animation with the rig. Then, I set the Animation Priority to “action” and exported it to Roblox. Then, I put the animation object inside the tool, and set the animation ID in the animation. Finally, I created the script and put that code in there.
Information about what I did wrong might be above. There are some people in the comments of that video that’s saying it doesn’t work for them. I have no idea how to script as I’ve never really scripted before for a Roblox game.