Why is the animation not replicated on the server? [Solved]

In fact I tried to do it in a server script but it is worse, besides I get this error and I do not understand why:
image

This is the code:

local Tool = script.Parent
local Player = game:GetService("Players")
local Character = Tool.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://6350259222"
local AnimationTrack = Animator:LoadAnimation(Anim)
local Anim2 = Instance.new("Animation")
Anim2.AnimationId = "rbxassetid://6364334315"
local AnimationTrack2 = Animator:LoadAnimation(Anim2)
local db = false

--Animation
Tool.Equipped:Connect(function()
	AnimationTrack:Play()
	AnimationTrack.Priority = Enum.AnimationPriority.Idle
	Humanoid.UseJumpPower = true
	Humanoid.WalkSpeed = 0
	Humanoid.JumpPower = 0
end)
Tool.Activated:Connect(function()
	if db == false then
		db = true
		AnimationTrack2:Play()
		AnimationTrack2.Priority = Enum.AnimationPriority.Action
		Player.leaderstats.Strength.Value = Player.leaderstats.Strength.Value + 1
		wait(2)
		db = false
	end
end)
Tool.Unequipped:Connect(function()
	AnimationTrack:Stop()
	AnimationTrack2:Stop()
	Humanoid.UseJumpPower = true
	Humanoid.WalkSpeed = 16
	Humanoid.JumpPower = 50
end)

It is similar to the previous one but with a small change, the animation does not replicate well neither on the client nor on the server.

OMG I found an issue for you. Infinite yield possible means it is stuck on finding that specific instance that was stated in the script. Use FindFirstChild, because if it returns nil, it returns nil instead of erroring!

I tried to do that too but I get this error now:
image

That error message means the parent is the item not found. FindFirstChild cannot be called because there is nothing to search.

So what do you think I should do to fix this problem, I have tried everything but it only seems to work on the client but not on the server.

I have my suspicions, but nothing concrete yet. Animation replication happens if the model is on the server, so I suspect you are animating an instance.

Putting the Humanoid in the backpack feels like an error. Is that where the motor6Ds are? I only put humanoids in the model that is moving (the character, the npc, the random object on the ground…). The backpack most likely creates an instance for the player. That Humanoid would only exist on the client(?)

Try animating from the character. It’s not concrete, but it’s a place to start.

in fact I was trying to animate the character along with a tool, it’s just that the tool animations are not replicated correctly and the scripts are inside the tool.

One sec. Something has changed. Earlier I saw reference to a second Humanoid, but that is not there anymore. I may have accidentally switched threads mid post. Going back over this code.

in fact, I made it myself in blender and it’s in StarterPack

1 Like

OK, I found what I was looking for:

It wasn’t in the code, it was in the error message.

Humanoid is in Character, but your error message is looking for it in Backpack! Your character definition is incorrect.

Change this:

local Character = Tool.Parent

to

local Character = Player.Character

see if that helps with the error. I had mistaken this for a second Humanoid the first time through.

I tried but I get this error:

You typed Players with an S. It should be singular. (Line 3)

In fact I wrote players because the variable is at the top obtaining the service of players.

Let me know if there are any more errors to hammer out, then we can go back to checking the replication part.

So far the FindFirstChild error is the only one that jumps in the OutPut.

Which line? Did you fix the Character definition? Players refers to the service. Player refers to the player.

You have to eliminate all errors for the script to run.

the error line is the Character variable

Oh, I see. I must be going cross-eyed today. Player is broken too! I recommend this solution here:

This will also give you the backpack, so you need one more Parent in there. Maybe it’s better at this point to eliminate Player from your script completely and fix your Character line with the extra Parent.

local Character = tool.Parent.Parent

I tried and I no longer get the FindFirstChild error but now I get another error telling me that it cannot load the animation and it refers to the AnimationTrack variable:

OK, AnimClipProvider is a service I never use. By the look of it, you never use it either. I only see one thing wrong with that line: “AnimationTrack” is a specific object, and is a reserved name(?) Try calling it “AnimTrack”?

AnimationTrack (roblox.com)