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

How Do You Put an Animation in a Tool?

Asked by 10 years ago

Excuse my noobyness, but I have recently built a Roblox nightclub (http://www.roblox.com/BETA-The-Cavern-Club-v1-2-MUSIC-ROOMS-place?id=152115919), and I am currently putting the finishing touches on it, and one of those finishing touches is putting "dance" animations in the tools. Now, I have VERY LITTLE EXPERIENCE with scripting, and I have tried to get this to work but it hasn't. I created a tool and put it in the starter pack. Then I put my animation in the tool. After that, I put this script in the tool (which was a combination of scripts I'd found online)

mouse.Button1Down:connect(Function) local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=144884906" end

I put this all in a local script and put my animation ID in there. You'll probably laugh when you see this, but I'm very new to scripting, please help me.

0
Hello I am in a similar problem except I am making a weight simulator but idk how to make the animation work and if I do i still need help on how to add a certain amount per lift. (Weight: Dominus) tennesseevols94 0 — 6y

2 answers

Log in to vote
3
Answered by 10 years ago

You're halfway there. You just need to load the animation into the humanoid and then play the animation. I would also recommend using a HopperBin instead of a Tool, as a Tool requires a Handle part to work (unless you've already got a Handle in the tool, in that case just ignore that).

So basically, you make a HopperBin in StarterPack (given if you have a Handle part in the tool or not), and then add this into a LocalScript inisde the HopperBin/Tool:

Tool = script.Parent
local player = game.Players.LocalPlayer
repeat wait() until player.Character ~= nil
local hum = player.Character:WaitForChild("Humanoid")

local animation = Tool.DanceAnim --Change DanceAnim to the name of your animation.
local AnimTrack = hum:LoadAnimation(animation) --Loads the animation into the humanoid.

Tool.Selected:connect(function(mouse) --If you're using a tool, change Selected to Activated, and get rid of the code on the next line. Otherwise, keep this the same.
    mouse.Button1Down(connect(function() --As mentioned above, delete this line if you're using a tool.
        AnimTrack:Play()
    end)
end)

Tool.Deselected:connect(function() --If you're using a tool, change Deselected to Unequipped. Otherwise keep it the same.
    AnimTrack:Stop()
end)

This may or may not work, I have NOT tested this. Tell me if the script doesn't work and I'll do my best to fix it.

0
@Spongocardo Thanks so much! phoenixroby 0 — 10y
0
No problem, be sure to accept my answer and upvote it if it helped, it helps me a lot! Spongocardo 1991 — 10y
0
I'd love to give you a upvote but im new on here, your answer helped me with a animation problem :D NepalClamps 13 — 6y
0
@NepalClamps You're welcome, glad I could help. Spongocardo 1991 — 6y
View all comments (2 more)
0
Hello I am in a similar problem except I am making a weight simulator but idk how to make the animation work and if I do i still need help on how to add a certain amount per lift. (Weight: Dominus) tennesseevols94 0 — 6y
0
@Spongocardo thx , it really helped me morphmagicX 0 — 6y
Ad
Log in to vote
-5
Answered by
Azenix 1
10 years ago

I can't Really Tell what your doing wrong but seeing from your code you definitly are new and you need to find other scripts and maybe even go to roblox wiki they have plenty of help there Your function event is written wrong

Answer this question