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

Won't load an Animation?

Asked by 10 years ago

I want to make it so when you click a Button, it loads an animation, but it won't work.

local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local example = Humanoid:LoadAnimation(script.Parent.Anim)

example:Play()

The Animation ID is set such as: "http://www.roblox.com/asset/?id=IDHERE"

1 answer

Log in to vote
1
Answered by 10 years ago

To use LocalPlayer you need to have this in a Local Script in a player's PlayerGui/Backpack (StarterPack) this means you would have to define the button as something like:

button = game.Workspace.Button

button.ClickDetector.MouseClick:connect(function()
    local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
    local Example = Humanoid:LoadAnimation(script.Parent.Anim)
    Example:Play()
end)
Ad

Answer this question