Problem with AnimationTrack in local Script

Hello everyone, I have a problem with my animation that does not want to play when fired in a local script. I think it has to do with the AnimationTrack but I am not sure.

This is also my first time scripting with animation so any extra information is appreciated.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local remote = ReplicatedStorage.Events.Remote:FindFirstChild("TestMoveRemote")
local Players = game:GetService("Players") 
local Debounce = true
local Animation = ReplicatedStorage.Assets.Animations.TestAnimEvent:Clone()
local mouse = Players.LocalPlayer:GetMouse()
local Humanoid = Players.LocalPlayer.Character.Humanoid


UserInputService.InputBegan:Connect(function(input, gameProcessedEvent, mouse)
	if gameProcessedEvent then
		return
	end
	
	if Debounce == false then
		return
	end
	
	if input.KeyCode == Enum.KeyCode.E then
		Debounce = false
			
		local AnimationTrack = Humanoid:LoadAnimation(Animation)
                AnimationTrack.Priority =  Enum.AnimationPriority.Action4
		AnimationTrack:Play()
		
		local mouse = Players.LocalPlayer:GetMouse()
			remote:FireServer(mouse.Hit)
			wait(1)
		Debounce = true
	end
end)

Thanks for your time!

2 Likes

Hi there. I’m not exactly sure if ReplicatedStorage.Assets.Animations.TestAnimEvent is an animation object? Also I don’t see you setting the parent of the cloned animation.

3 Likes

It is in the right place but where should I parent the animation?

Is it even needed to Clone the animation?

I don’t know where you’re keeping the animation. There is no need to clone it before loading it into the humanoid/animator.