I made a script where if you equip a tool, it should play an animation, except it doesn’t play at all when you equip it.
I’ve tried rewriting the script many times and it still doesn’t work. The animation is tied to the group where the game is created, I’ve even tried changing the animation priority to every option, and I’ve also tried looking at DevForum but none of the solutions are what I’m looking for.
Update: I’m stupid and I forgot to put a handle in, BUT is there an alternative to it WITHOUT having to have a handle?
local tool = script.Parent
local animation = tool:FindFirstChild("Animation")
local function onEquipped()
local character = tool.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid and animation then
local animator = humanoid:FindFirstChildOfClass("Animator")
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()
end
end
tool.Equipped:Connect(onEquipped)
A handle is required to have a tool to be.. a tool. It’s essentially an attachment point for where the tool originates when held by the player.
I’m not versed enough in the subject to say definitively a yes or no, but it is most convenient to have a handle. I assume that without a handle you’d have to make it into a limb of the character, which has its own complications, most of it being it wouldn’t be as easy as a normal tool to just have a player equip it.
But for the animation not playing upon equipping, you have several ways to troubleshoot. You can check if it throws an error, or if the script is firing at all. For example, you can make something that prints a message in this area:
If you put a :warn() or :print(), this could definitely help troubleshoot. Good luck.