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

How to make an animation work in tool, when I equip it and then left-click?

How to make an animation in tool script? Like when I equip a tool and then left-click, an animation would trigger. How would I make that?

2 answers

✓ Accepted answer

I am at school atm, this means I can't test this code. Let me know if there are any problems.

PLEASE read the comments!

--// In LocalScript

local Player = game.Players.LocalPlayer --finds player
local Character = Player.Character or Player.CharacterAdded:Wait() --find player's character, if not, waits for character to be added

TOOL.Equipped:Connect(function() --when we equip the tool
    TOOL.Activated:Connect(function() --when we click when having the tool equipped
        local Anim = Instance.new('Animation', Character) --makes animation
        Anim.AnimationId = 000000000 --id here
        
        PlayAnim = Character.Humanoid:LoadAnimation(Anim) --this is a global variable so that we can call the "Stop()" function to stop the animation outside the Equipped function.
        PlayAnim:Play()
    end)
end)

TOOL.UnEquipped:Connect(function() --when we unequip the tool
    PlayAnim:Stop()
end)

9 comments

0

Notice: When I have "TOOL", this is where you would find your tool. If your localscript is directly in the tool, replace "TOOL" with "script.Parent". So it would look like: script.Parent.Equipped:Connect(function()

0

Ah, thank you for helping.. But sadly it didn't work. :c

0

Any error?

0

Any errorrr???

0

20:47:32.404 - Stack Begin 20:47:32.405 - Script 'Workspace.GiveSystem.Script', Line 66 20:47:32.406 - Stack End Cutscene Editor Loaded 20:47:40.837 - UnEquipped is not a valid member of Tool 20:47:40.840 - Stack Begin 20:47:40.841 - Script 'Workspace.Player1.ew.LocalScript', Line 17 20:47:40.842 - Stack End 20:47:41.454 - Animation "720906007" failed to load in "Workspace.Player1.Animation.Animat

0

You dont' use unequipped ya use deactivated

0

change "TOOL.UnEquipped" to "TOOL.Unequipped"

0

TYSM! Thanks for helping guys! :D

0

Np

script.Parent.Equipped:connect(function(namewhat)
script.Parent.Activated:connect(function(click)
	-- animation script here
end)
end)

1 comment

0

Apperantly this might not be a request site but i'll still try to help you

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