How Would I play an emote when a player chatted

I’m having trouble finding when a player chatted something like /compress, which if a player typed that, it would play a compression animation on that player. The problem is, i tried looking through the devforum, and API reference, but I still can’t find an answer. Could someone help me out?
Thanks.

Sorry for the late response, but you can play animations like this -

local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://5286409102"
local PlayAnim = Character.Humanoid:LoadAnimation(Anim)

local function playAnimation()
    PlayAnim:Play()
end

Just make sure to put that in a local script. You can either fire playAnimation() or just do PlayAnim:Play() whenever the player chats whatever it is you want.

If you wanted to play an animation on chat, you could do something like:

local player = game.Players.LocalPlayer
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://(id here)"
local play = player.Character:WaitForChild("Humanoid"):LoadAnimation(anim)

player.Chatted:Connect(function(msg)
    if (msg=="/compress") then
        play:Play()
    end
end)
1 Like

Thanks alot! It worked. Had to customize it a bit though.

I’m also having a bit of trouble on another thing on my game. Click on my profile then on the featured topic thing. I’m having trouble with a script that destroys a part. @Rakyo @alimm123