Stabbing Animation not playing when tool active

Hi,

Not sure if this is a coding or building issue, but I am trying to understand how to make an stabbing animation.

I inserted a R15 rig and with the animator did a stabbing animation and saved to Roblox.

I codeded in a localscript in StarterPlayerScripts to play the animation when the player pressed a key and it works, but when I equip a tool the animation will not play.

What am I doing wrong, do I play the stabbing animation in a script under the tool or am I doing something stupid.

Thanks

1 Like

Can we see some code? That might help me help you

One way of scripting this would to do this.

Put a script into the tool.

And here is the code

local tool = script.Parent

local equipped = false -- this is used to tell if the tool is equipped

local player = game:GetService('Players').LocalPlayer

local hum = player.Character.Humanoid

local anim = 'YOUR ANIMATION. PUT IT HERE. you can parent the animation under the tool and then get it with this variable'

tool.Equipped:Connect(function()
     equipped = true -- this runs when the tool is equipped
end)

tool.Unequipped:Connect(function()
     equipped = false -- This runs when the tool is unequipped
end)


local loadedAnim = hum:LoadAnimation(anim) 

local function activate() -- you activate this function when you want it to play an animation
      if equipped == true then -- make sure it is equipped
              loadedAnim:Play() -- this will play the animation
      end
end


The reason we load the animation is cause other wise the animation wont play.

You need to load the anim to the player(Anim is short for animation)

Make sure that the Anim variable is set to the Animation you want it to use.

If you have any questions tell me!