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

How could I fix my custom emote script that doesn't work?

Asked by 3 years ago
Edited 3 years ago

I'm trying to add custom emotes into my game, but there are a few bugs with the animations

Heres what happens when you start walking https://gyazo.com/bc9b9112f40d8a38c29366edfc77e1aa (Link doesn't work, so to see the issue you have to copy or paste in your browser, or don't)

Code

local plr = game:GetService('Players').LocalPlayer
local emotes = {
    sit = "rbxassetid://withdrawn",
};

function stopAnims()
    local Humanoid = game.Players.LocalPlayer.Character.Humanoid
    local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
    for _,v in pairs(ActiveTracks) do
        v:Stop()
    end
end

for i,v in pairs(emotes) do
    local anim = Instance.new('Animation')
    anim.AnimationId = v
    emotes[i] = plr.Character.Humanoid:LoadAnimation(anim)
    emotes[i].Priority = Enum.AnimationPriority.Core
end

plr.Chatted:connect(function(message)
    if message:sub(1,3) == "/e " then
        local emote = message:sub(4)
        emote = emotes[emote]
        if emote then
            if not emote.IsPlaying then
                stopAnims()
                emote:Play()
            end
        end
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Since you're walking when you try to sit, roblox is already playing an animation so it won't let you play another. The easiest fix would to be setting their walkspeed to 0 for a second so it can play.

if not emote.IsPlaying then
    plr.Walkspeed = 0
    stopAnims()
        emote:Play()
0
The thing is, canceling the emote would be an issue, and also the way the rounds work, I don't think the player would want to be frozen at the start of the round and be instantly killed. ArvidSilverlock 50 — 3y
Ad

Answer this question