How to make a button play an animation?

Hey!

I am wondering, if there is any tutorials out there that show how I can make a button play an animation on a player? I am making a Emote Menu.

Let me know what you can find, thanks!

Sincerely,

papahetfan

--Client (local script) in a text button
script.Parent.MouseButton1Down:Connect(function()
local character = game.Players.LocalPlayer.Character
local hum = character:FindFirstChild("Humanoid")
hum.Animator:LoadAnimation(game.RepliactedStorage.YourAnimation):Play()
print ("playing")
end)

Did this work?

local button = script.Parent
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()



button.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		character.Humanoid:LoadAnimation(script.Animation)
		print("dado")
	end
end)

put a local script with that code inside the button and put an animation inside the local script with the animation id you want to be played when clicked

.

Humanoid:LoadAnimation() and you dont have to do that, you can use mouse button 1 down

I used that just in case he wants to make it in a frame or something and what’s wrong with humanoid:LoadAnimation()? It works fine

Humanoid:LoadAnimation() is depracted and you should use call it on the Animator instead.

Humanoid.Animator:LoadAnimation()?