Animation doesn't work the way it should in game

It’s as the title says. I’ve look into other posts with similar problems, but I still do not understand why. Since it’s a box model, the rigging is very simple, and these are my own animations, so I’m not sharing it with a group. AnimationPriority is set to Action, yet it still behaves this way. Is there something that I’m missing, or is this entirely something else?

Videos

In studio:


In game:

Scripts
--// Script
local animationController = script.Parent:WaitForChild("AnimationController")
local animationsFolder = script.Parent.Animations

local root = script.Parent.Root
local state = false

root.ClickDetector.MouseClick:Connect(function(player)
	if not state then
		state = true
		local anim = animationController.Animator:LoadAnimation(animationsFolder.Open)
		anim:Play()
	elseif state then
		state = false
		local anim = animationController.Animator:LoadAnimation(animationsFolder.Close)
		anim:Play()
	end
end)
1 Like

It’s just an animation so it’ll just go back to it’s normal state after the animation plays. Think about how a sword swing animation works on Roblox, when you swing it it swings, after swinging it goes back to your normal animation. You’ll need another script to set it so that after playing it opens.

1 Like

Hmm, so does that mean I’ll need to make a type of “idle animation” for the boxes in whatever state it’s in?

1 Like

That would work, but I suggest just anchoring the model like 0.1 seconds before it finishes so that the model will just stays open. You could make an idle animation though.
I also suggest using tween services, might be easier with that too.

I tried using idle animations, but the problem persists after several open-close cycles. I’ve tried anchoring the parts and it worked for the opening animation, however, when I unanchored to let the close animation play, there’s a short interval where it skips to its normal state then proceeds with the animation. I’m currently looking towards freezing the animation using AdjustSpeed function, so I’ll see where this leads.

Alright, I was able to fix it. By using Animation Events and GetMarkerReachedSignal function, I’m able to set a marker (or Animation Event) at a specific time position. Once the animation reached the marker, I’ve set the speed of the animation to 0, essentially freezing it. I did think of using TweenService, however, it’s such a pain, especially for bigger, more complicated models. Nonetheless, thanks for the suggestions! Glad it worked out in the end.