Why doesn't the animation load?

game.ReplicatedStorage.Selected.OnClientEvent:Connect(function(player , Clone)
	  if Player:FindFirstChild("Shield1") then
		local Animations =Player:WaitForChild("Shield1"):FindFirstChild("Animations")
		local Block = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Blocking)
		local Punch3 = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Punch3)
		local punch2 = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Punch2)
		local EquipAnimation = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Equip)
		local UnEquipAnimation = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Unequip)
		local Punch1 = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.punch1)
		local Holding = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Holding)
		
	  elseif Player:FindFirstChild("Shield") then
			
		local Animations = player.Character:FindFirstChild("Shield").Animations  
		local Block = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Blocking)
		local Punch3 = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Punch3)
		local punch2 = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Punch2)
		local EquipAnimation = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Equip)
		local UnEquipAnimation = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Unequip)
		local Punch1 = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.punch1)
		local Holding = Character:WaitForChild("Humanoid"):LoadAnimation(Animations.Holding)
	
	

The rest of the script is where the animation is played
when the player press a key but it doesn’t load for some reasons

also bot end and end) are down of the script so it can read the animations

1 Like

try loading the animation into the animator inside the humanoid instead of the humanoid itself

1 Like

It didn’t work

This text will be blurred

1 Like

What exactly do you mean by it won’t load? I don’t see a reason for it to not load.

2 Likes

My bad i forgot to mention that this is a client script and when the server script fires the client with the player who fired it the client will load the animation but it won’t load it for somereasons

I updated a part of the script here it is:

game.ReplicatedStorage.Selected.OnClientEvent:Connect(function(player , Clone)
	
	local Animations =Player:WaitForChild("Shield1"):FindFirstChild("Animations") or Player:WaitForChild("Shield"):FindFirstChild("Animations")
		local Block = Character:WaitForChild("Humanoid").Animator:LoadAnimation(Animations.Blocking)
		local Punch3 = Character:WaitForChild("Humanoid").Animator:LoadAnimation(Animations.Punch3)
		local punch2 = Character:WaitForChild("Humanoid").Animator:LoadAnimation(Animations.Punch2)
		local EquipAnimation = Character:WaitForChild("Humanoid").Animator:LoadAnimation(Animations.Equip)
		local UnEquipAnimation = Character:WaitForChild("Humanoid").Animator:LoadAnimation(Animations.Unequip)
		local Punch1 = Character:WaitForChild("Humanoid").Animator:LoadAnimation(Animations.punch1)
		local Holding = Character:WaitForChild("Humanoid").Animator:LoadAnimation(Animations.Holding)
		

I didn’t copy the rest so it be easier to read also it now gives me a new error

Infinite yield possible on 'Players.wolfmanOs:WaitForChild(“Shield1”)

1 Like

Your code probably is being infinitely yielded by :WaitForChild() just use :FindFirstChild instead and check if Shield1 or Shield exists first.

2 Likes

Now it gives me this

Workspace.wolfmanOs.Shield_Client:54: attempt to index nil with ‘FindFirstChild’ - Client - Shield_Client:54

1 Like

You would have to check if those instances exist first then check for the animation folder. Also make sure you’re referencing the right thing or that it’s under the player object.

3 Likes

It exists This text will be blurred

1 Like

Let me see where you’re putting you animations in the explorer because if it’s still erroring or yielding you’re either referencing the wrong thing or it doesn’t exist.

2 Likes

Here it is when the game is running

Screenshot (35)
And here it is when the game is not

Screenshot (36)

1 Like

You’re trying to get the shields from the player object you need to get it from the character instead. Just replace Player with Player.Character should fix your issue.

2 Likes

It didn’t work it says that its not a valid member

1 Like

I forgot to mention since you’re using a local script the remote events do not pass player variables so delete that and redefine player as game.Players.LocalPlayer

2 Likes

Dont worry after hours i found a simpler way and it worked but thanks also for your help.
And sorry i didn’t see your last reply because i was trying to change the way am making the player doing the animation.

1 Like

That’s great, glad I could assist

1 Like