I want to make an emote button so that when you press the key once, the animation and a sound play you can't move or jump. and when you press that exact key again the emote and sound stop and you are able to walk and jump again.
COMMUNITY QUESTION
How To Play An Animation By Pressing A Key?
1 answer
I couldn't find anything that "you can't move or jump" but there is a code that i made:
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Animation = Humanoid:LoadAnimation(script:WaitForChild("Animation"))
local Keybind = Enum.KeyCode.(key)
UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
if Input.KeyCode == Keybind then
Animation:Play()
end
end)
Make this as a LocalScript in StarterPlayer > StarterCharacterScripts and inside of it, add Animation and put id of the animation that you want. (Oh and also, in script you will see "(key)", replace it to whatever you want.)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
thanks, im just gonna edit it to my liking