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

How do you link an animation into a certain script?

Asked by 10 years ago

I want to use certain animations for a gear I am working on, but I don't know enough about Lua to know how to do so.

1 answer

Log in to vote
3
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

Well if you don't know anything about Lua then I suggest starting and taking some tutorials at the wiki, getting lessons from someone, or looking at youtube videos.

If you do know some things about Lua then, there's a certain method for animations. Once you've created and uploaded your animations then you can start to code your gear. At certain parts in the script you'll need to play your animations, you do this with the :Play() method. But first you have to load the animation into the player's humanoid. You do this with the :LoadAnimation() method After you've loaded the humanoid with the animation then you can play them. But even before that you're going to need to create the animation object and set it's ID to your wanted animation.

The sequence is like this:

Create Amination Object

-Set it's AnimationId

--Load the animation into a humanoid

---Play the aimation loaded into the humanoid

The outcome will look something like this;

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=000000000"
local Anim

tool.Equipped:connect(function(mouse)
    local hum = tool.Parent:FindFirstChild("Humanoid")
    Anim = hum:LoadAnimation(animation)
    tool.Button1Down:connect(function()
        Anim:Play()
    end)
end)

You can read more about animations here

0
This helps alot, thanks! TokumeiNo 15 — 10y
0
No problem(: Goulstem 8144 — 10y
Ad

Answer this question