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

How to play an animation with a tool?

Hello. I made an animation and a script for a tool. When I click, the animation is supposed to play. Instead nothing happens. If I quickly unequip the tool, the animation plays. Is there a way to make the animation play WITH the tool?

Here is the script:

function onClicked(plr)
	local ex = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
	ex:Play()
end

script.Parent.Activated:connect(onClicked)

Thanks

1 answer

Make this script below a local script after making, this goes in the tool.

plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
function onClicked(plr)
send = script.Parent.Send--Make a RemoveEvent in the tool as well, name it "Send" .
Send:FireServer()
end

mouse.Button1Down:connect(onClicked)

Make this script below a script after making, this goes in the tool.


send = script.Parent.Send

send.OnServerEvent:connect(function(plr)
	ex = plr.Character.Humanoid:LoadAnimation(script.Parent.Animation)
    ex:Play(1.0)
end)

Thats it! If this worked please mark my question the answer so I can get more reputation so I can help others.

10 comments

0

Thanks for posting. Sadly these scripts do the same thing as my original script.

0

Can I have the animation ID?

0

Sure, the ID is 1579421340

0

Alright, let me do some testing

0

Ok thanks

0

It says the ID is invalid..Are you sure its correct?

0

Yes I'm sure it is correct, here is the animation. https://www.roblox.com/library/1579421340/Drink2

0

Look at the edit, I also found out I cant help you anymore, I found out the Animation only works with the "owner" of the animation.

0

The new script didn't work, but thanks for trying to help anyway.

0

Welcome.

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