Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Tool plays animation when I unequip it?

My tool is supposed to play a animation that when I click on it it plays a animation but my tool isn't doing that its doing the opposite when the animation is supposed to play when equipped its not playing when equipped it only plays when i equip the weapon and I have clicked to fire the event

here is my local script on this tool

tool = script.Parent

animation = tool:WaitForChild("Animation")

equip = false

  

  

tool.Activated:Connect(function()

if equip == true then

Hum = tool.Parent:FindFirstChild('Humanoid')

Hum:LoadAnimation(animation):Play()

end

end)

  

tool.Equipped:Connect(function()

equip = true

  

end)

  

tool.Unequipped:Connect(function()

equip = false

end)

1 comment

0

The activated event fires when the tool is equipped and then clicked, if you want the animation to play as soon as you equip the weapon, then simply move the code block pertaining to the animation being loaded into the Equipped function

1 answer

tool = script.Parent animation = tool:WaitForChild("Animation") equip = false --move the equipped/unequipped functions above the activated function, so it can check whether equipped is true or false tool.Equipped:Connect(function() equip = true end)

tool.Unequipped:Connect(function() equip = false end)

tool.Activated:Connect(function() if equip == true then Hum = tool.Parent:FindFirstChild('Humanoid') Hum:LoadAnimation(animation):Play() end end)

This discussion is preserved as it was. New answers, comments, and votes are closed.