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

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

Asked by 7 years ago

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

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago

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)
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() FiredDusk 1466 — 7y
0
Ah, thank you for helping.. But sadly it didn't work. :c ItzMeDenise 18 — 7y
0
Any error? FiredDusk 1466 — 7y
0
Any errorrr??? FiredDusk 1466 — 7y
View all comments (5 more)
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 ItzMeDenise 18 — 7y
0
You dont' use unequipped ya use deactivated farrizbb 465 — 7y
0
change "TOOL.UnEquipped" to "TOOL.Unequipped" FiredDusk 1466 — 7y
0
TYSM! Thanks for helping guys! :D ItzMeDenise 18 — 7y
0
Np FiredDusk 1466 — 7y
Ad
Log in to vote
0
Answered by
farrizbb 465 Moderation Voter
7 years ago
Edited 7 years ago
script.Parent.Equipped:connect(function(namewhat)
script.Parent.Activated:connect(function(click)
    -- animation script here
end)
end)
0
Apperantly this might not be a request site but i'll still try to help you kristibezatlliu1111 33 — 7y

Answer this question