Animation not working [unsolved]

Hello everyone,

For me its my first time using animation in scripts and I am having some issues with playing the script. The script is client-sided and gives no error code.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local remote = ReplicatedStorage.Events.Remote:FindFirstChild("RemoteEvent")
local Players = game:GetService("Players") 
local Debounce = true
local Animation = ReplicatedStorage.Assets.Animations.TestAnimEvent
local Humanoid = Players.LocalPlayer.Character:FindFirstChild("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:Play()
			
		local mouse = Players.LocalPlayer:GetMouse()
	
			remote:FireServer(mouse.Hit)
			wait(1)
		Debounce = true
	end
end)

Can anyone help me the cause of this problem?

Thanks!

2 Likes

Hey, try replacing Humanoid with Humanoid.Animator.

If this simple tip fails- I will put research into this, and I will come back once I find a solution.

1 Like

It still does not work, does it have to do with the animation itself?

1 Like

Maybe, try opening your Animation in the Animation Editor, then click the three dots, and go to Set Animation Priority. Tell me what it is checked at.

It is set on action. how can that matter?

Alright, usually if its set lower, it won’t display properly.

Alright- to collect more information, how does this work?

  1. Where is the script location?
  2. It’s client sided, yes? Make sure its in either StarterPlayerScripts or StarterCharacterScripts.
  3. Add some print statements at the start of the function- then before and after the if input.KeyCode statement. Does it print out all functions?

Since there are no errors, it makes this slightly trickier. I would appreciate it if you answered all these questions within one post.

1 Like

1&2. its in StarterPlayerScripts
3 I don’t think that would work because if that is so how can the remote event after that be fired if there’s an error

Well, I was never told that the RemoteEvent fired or not. However, I’d recommend-

  1. Make an IntValue- place it under the script. Name it “AnimationID”
  2. Set the value of IntValue to the same AnimationId of the “TestAnimEvent”.
  3. Now, Inside the Script, replace the Animation variable with this.
local Animation = Instance.new("Animation")
Animation.Parent = script
Animation.Name = "TestAnimEvent"
Animation.AnimationId = script.AnimationID.Value

Tell me if this works.

it is still not working but thank you for your input.