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

Won't load an Animation?

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

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)

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