Animation doesn't always play

Hello,

I have a script in a folder, inside of that folder there are blocks. If you click a block an animation plays for that block, but the animation doesn’t work for some blocks.

Script: (I have deleted a portion of the script and left the animation part with its variables)

for i, LuckyBlock in ipairs(script.Parent:GetChildren()) do
	if LuckyBlock:IsA("Model") then

		local ClickDetector = LuckyBlock.ClickDetector

		local debounce = false

		ClickDetector.MouseClick:Connect(function(Player)
			if debounce == false then
				debounce = true

				local Animation = script:WaitForChild("OpenAnimation") 
				local AnimationController = LuckyBlock:WaitForChild("AnimationController")
				local Open = AnimationController:WaitForChild("Animator"):LoadAnimation(Animation)
					        wait(0.25)
						Open:Play()
					end
				end)	
			end	
		end
1 Like

Is there any difference between the blocks it does work on, and the blocks it doesn’t work on?
Do you get any errors when it doesn’t work? If yes, what errors?

There is no difference between the blocks and there are no errors.

Are they exact copies of one another? Also is it possible that “debounce” already is false in some cases, making the script not run?

They are exact copies (only different names), and when I join a new server and open a block it still won’t open but it does play the animation on some other blocks. So it works on some blocks but not on every block.

Strange… mind sending an image of the explorer with one block that does work and another that doesn’t? If that is possible.

The problem is fixed! The issue was that the animated part was anchored :sweat_smile:. Sorry for the inconveniencece.

1 Like

Oh :laughing: Didn’t think of that…
Great that you solved it!

Have a nice day! Thank you for the help anyways!

1 Like