I am trying to make an animation play when a tool is activated, but I don't know how. For some weird reason, if I equip the tool, activate it, and unequip it super fast, it shows part of the animation playing and it won't print the error message, so I think it is trying to play, but I can't see it because because the tool being equipped won't allow it to play. Can someone tell me how to play an animation when a tool is activated? I want to make a throwable pizza for a food fighting game, and I need to play a throwing animation right when the tool is activated to make my character move the tool in a way that it looks like I am throwing it. Another thing - is it possible to do this? Do I need to change my scripts?
wait() local CanEmote = true local Player = game.Players.LocalPlayer local character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = character.Humanoid local Animation = Humanoid:LoadAnimation(script.Throw) script.Parent.Activated:Connect(function() if CanEmote then Animation:Play() CanEmote = false wait(1) CanEmote = true else print("An Error Occured") end end)
After having a discussion with you, I have came up with this script:
-- script doesn't work.
Edit: I think what you need to do is detect if it's selected and when the mouse button clicked, then set it to active.
Tell me if this works. Thanks xx.