I want to have a shopkeeper NPC do a quick animation and then change her idle animation until the player leaves the shop. When the player leaves, she does another quick animation and returns to her default idle. The problem is that the NPC has that default idle animation set beforehand, and instead of overwriting that animation, it seems to play both of them on top of each other. I was able to get it to sort of work when I changed the priority on the in shop idle animation to Action, but that caused way more issues. Is there any way I can fix this? This used to work about a year ago but I assume ROBLOX did an update that completely broke my code.
Here’s a video of what I want to achieve : (I know it’s a bit hard to see, but in the second part her back is more hunched over, it looks like a combination of her in shop idle and regular idle animations)
And here’s a snippet of the local script : (it’s under StarterPlayer.StarterPlayerScripts)
local ReplicatedStorage = game:GetService("ReplicatedStorage").shopEvents;
local cueAnim = ReplicatedStorage:WaitForChild("cueAnim");
local triggerGUI = game.ReplicatedStorage:WaitForChild("triggerGUI4Shop");
-- for animation
local anim = game.Workspace["Convenience Store Owner"].Anim;
function playanimation(action)
--animations
local idle = anim.idle;
local flipIn = anim.flipIn;
local inShopIdle = anim.inShopIdle;
local itemBought = anim.itemBought;
local flipOut = anim.flipOut;
local loadedanimation;
local npcAnimator = game.Workspace["Convenience Store Owner"].Humanoid:WaitForChild("Animator");
if action == 0 then -- OPEN SHOP
loadedanimation = npcAnimator:LoadAnimation(flipIn); -- priority : action
loadedanimation:Play();-- works perfect
wait(.5);
triggerGUI:Fire(); -- gui opens mid-her animation
wait(.54);
--inShopIdle's priority is Idle, and should overwrite the current idle anim
loadedanimation = npcAnimator:LoadAnimation(inShopIdle);
loadedanimation:Play(); -- this throws no error?
print("animation has been played"); -- this DOES fire, but the inShopIdle animation does not act as intended
-- this is just a snippet, there's more but it's all the same format as above with different animations
I’m sure someone already solved this somewhere, but when I was looking on the forums most people had this issue with players, not NPCs. Any help is greatly appreciated!!