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

How To Play An Animation By Pressing A Key?

Asked by 1 year ago
Edited 1 year ago

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.

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

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.)

0
thanks, im just gonna edit it to my liking JmoneyPlayzOfficial 49 — 1y
Ad

Answer this question