So I made a GUI that is supposed to play an animation upon being clicked on. I put a local script in every one of the Button Labels and wrote this script:

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://8836638864"

local trackanimation = nil
local playability = true

function playAnimation (animationSource)
	if playability == true then
		local plr = game.Players.LocalPlayer
		trackanimation = plr.Character.Humanoid:LoadAnimation (animation)
		
		trackanimation.KeyframeReached:Connect(function()
			print("Animation Successfully Played") --I put this in to test if it worked and it did
			
		end)
		trackanimation:Play()
	end
end
script.Parent.MouseButton1Click:Connect(playAnimation)

The thing is, it works in Studio but doesn't work in-game and I have a feeling that it has something to do with FE but I have no idea how to fix it and I have searched online but it didn't really apply to this. I hope somebody can help me figure it out!

3 comments

0

are you sure you own the animation?

0

Yes I made it myself. My username is PoInareffe since I changed it last year.

0

LoadAnimation is deprecated idk how that would relate to this issue tho