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

How could I make it so an animation would play when a tool is equipped?

Asked by 7 years ago

I've tried this,

handle = script.Parent.Handle

Weapon.Equipped:connect(function(mouse)
handle.idle:Play()

end)

This script works fine when playing a sound but I haven't been able to get it to work with animations.

0
Has the animation got an ID? And are you giving the tool enough time to load the animation? UltimateRaheem 75 — 7y
0
Use the humanoid:LoadAnimation(animation) function on the humanoid first. Master_JJ 229 — 7y

1 answer

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

Animations are a bit different. You need to load animations into the Players Humanoid.

LocalScript:

repeat wait() until game.Players.LocalPlayer.Character
local Player = game.Players.LocalPlayer
local anim = Player.Character.Humanoid:LoadAnimation(script.Animation)
local tool = script.Parent

tool.Equipped:connect(function()
    wait(0.5)
    anim:Play()
    wait(1.5)   
    anim:Stop()
end)

Please accept this answer if it solved your problem, thanks!

0
That script does not work. It's because of the fact that the Repeat requires an Until for it to work. Akkendran 16 — 7y
0
Oops, my bad, must've forgot that. Kind of wrote it in a haste. xXLegendarySoldierXx 129 — 7y
0
That's alright, I kinda sorta figured it out. Akkendran 16 — 7y
Ad

Answer this question