Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tool plays animation when I unequip it?

Asked by 5 years ago

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)
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 SerpentineKing 3885 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)

Ad

Answer this question