Animations not playing

I’m trying to play a few animations, but they aren’t playing. There is no error in the output window, but they won’t play. Here is the code:

local fridgePromt = script.Parent.MiddleShelf.FridgePrompt

local animator = script.Parent.FridgeCore.AnimationController.Animator
local openAnimation = Instance.new("Animation")
openAnimation.AnimationId = "rbxassetid://9120222702"
local openAnimTrack = animator:LoadAnimation(openAnimation)

local closeAnimation = Instance.new("Animation")
closeAnimation.AnimationId = "rbxassetid://9120235633"
local closeAnimTrack = animator:LoadAnimation(closeAnimation)

fridgePromt.Triggered:Connect(function(plr)
	local PlayerGui = plr:WaitForChild("PlayerGui")
	wait(0.3)
	local fridgeGui = PlayerGui.FridgeGUI.FridgeGUIFrame
	while fridgeGui.Visible == true do
		wait(0.3)
	end
	openAnimTrack:Play()
	wait(0.5)
	closeAnimTrack:Play()
end)
1 Like

Have you tried setting the AnimationPriority to “Action”?

You could try to debug the function first by adding a print("attempting to play") in front of the :Play() call. Is the “animator” created by the server?

No, the animator isn’t created by the server. Should it be?

If this is an NPC then its animations should be handled by the server (as the server has network ownership of the NPC).

It is not an NPC, it is a non-human rig.

In either case, server scripts should be used to handle animations on assemblies network owned by the server.

Yes, it is a server script, not a local script.

The animator was created by me, not through a script of any kind, that is what I meant.

Make a new dummy using the dummy creator plugin, unanchor the humanoidrootpart and apply your script to the character. If it works then it’s something with your rig and Motor6D’s, but if it doesn’t work, it’s something with your script. Although if it’s your script, I don’t know what to tell you, your script looks fine.

It’s not a human rig. It is a fridge.

I have done some debugging, and I figured out it is a client-server issue.

while fridgeGui.Visible == true do
     wait(0.3)
end

The code above is waiting for a player to click a button on a gui that shows up when they trigger the prompt. The button will make in not visible, but that is on the client side. As @Forummer explained to me in a different topic, as far as the server is concerned, the gui is still visible, so it will just keep waiting forever. I want to use RemoteEvents, but there will be multiple fridges in the restaurant, and I don’t want them all to open and close when someone triggers the prompt. How could I do this?

does the animation play/work?
could you try using a proximity prompt just to test it out?

The animation play function works.