How do I run an animation on a tool?

Hi. I followed some instructions on how to make an animation. I’ve come out with this:
anim.rbxl (18.3 KB)
(not meant to be pretty)

I couldn’t find any clear instructions on how I would turn this into an actual functioning tool. I’ve tried exporting the animation and tried to run it on a tool but what I tried did not work. Does anyone know how to do this properly?

Might want to look at this:

1 Like

I have that part already figured out. (Check out my gif or game file)

There is an existing post about this: How to run an animation onClick? - #4 by Stelrex

However if you don’t want to read through it, here is just a basic run down.

In order to run an animation when you click with the tool equipped, you have to detect that click. There are other ways to detect a click, but we’re going to use UIS:

local UIS = game:GetService("UserInputService")
local Players = game.Players

UIS.InputBegan:Connect(function(input, event)
if input.UserInputType == Enum.UserInputType.MouseButton1 and script.Parent.Equipped then
	local animation = Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
	animation:Play() --Because the animation is non-looping, it'll stop itself

Also, you will need an Animation instance in order for it to run. You can either just insert one into the model or anywhere you want (and replace script.Parent.Animation to wherever), or you can just do, up to you. Anyways I hope that helps! Read the other post if you want more info on it!

1 Like

Minor thing, but I would suggest bumping the arm up instead of the gun. It might turn out to be a bit easier to do as well. Other than that, the post above mine appears to be correct.