How to prevent my animations from conflicting with the animate scripts

I’m making it so that the walk/idle animations of the player are updated depending on their health.

I change the animation id’s in the animate script and set the definition of the animation ids in the script like so

	idle = 	{	
				{ id = script:WaitForChild("idle").Animation1.AnimationId, weight = 9 },
		{ id = script:WaitForChild("idle").Animation2.AnimationId, weight = 1 }
			},
	walk = 	{ 	
				{ id = script:WaitForChild("walk").WalkAnim.AnimationId, weight = 10 } 
			}, 
	run = 	{
				{ id = "run.xml", weight = 10 } 
			}, 

I then change their IDs with this script

local char = script.Parent

char.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()

	local health = char.Humanoid.Health

	if not char:FindFirstChild("brokenLeg") then --if you arent crippled (if you are, we want you to stay the same speed that you are)


		if health <= 20 then
			char.Humanoid.WalkSpeed = 7
			char.Humanoid.JumpHeight = 0
			script.Parent.Animate.walk.WalkAnim.AnimationId = "rbxassetid://10721931379"
			script.Parent.Animate.idle.Animation1.AnimationId = "rbxassetid://10721734194"
			script.Parent.Animate.idle.Animation2.AnimationId = "rbxassetid://10721734194"
		end

		if health >= 21 and health <= 50 then
			char.Humanoid.WalkSpeed = 12
			char.Humanoid.JumpHeight = 4
			script.Parent.Animate.walk.WalkAnim.AnimationId = "rbxassetid://10718081768"
			script.Parent.Animate.idle.Animation1.AnimationId = "rbxassetid://10718192940"
			script.Parent.Animate.idle.Animation2.AnimationId = "rbxassetid://10718192940"
		end

		if health > 50 then
			char.Humanoid.WalkSpeed = 16
			char.Humanoid.JumpHeight = 7.2
			script.Parent.Animate.walk.WalkAnim.AnimationId = "rbxassetid://10712693225"
			script.Parent.Animate.idle.Animation1.AnimationId = "rbxassetid://180435571"
			script.Parent.Animate.idle.Animation2.AnimationId = "rbxassetid://180435571"
		end


	end

end)

This works perfectly on the client, but when I look at it on the server, or from another player’s perspective, the animations are all janky, and it seems to look like a mix between the default roblox animations and my own. I don’t know how on earth this is happening or where to even begin to try and fix it, so hopefully some of yall can

This is probably wrong but maybe the animations aren’t loading and that’s why it’s someone what of a mix. And also it may also be because you check every single time the player takes/heals health.

If they work fine on the client, wouldn’t that mean they’ve loaded? And if they just haven’t loaded on the server, how am I supposed to deal with that?

Also when testing it I don’t get hurt/heal that often so I don’t see how that’d be an issue

Yeah that was somewhat of a wild guess and this probably depends on how quickly the player gets hurt after they join, but maybe do a WaitForChild() for the animations? (I’m not really experienced with animations so the problem might be something else entirely that relates to only animations)

where would i do that
like

script.Parent.Animate.idle:WaitForChild("Animation2").AnimationId = "rbxassetid://10721734194"

or something?
It doesn’t have any problem grabbing the animation i dont see why thats necessary

I mean if it doesn’t work on the server side, it could be because of that and you can also either
A. Define all the animation ids beforehand (while waiting for them)
B. Define them in the way you just showed

I’m pretty sure A would be the better option though.

The default ‘Animate’ script loads animations with a priority of ‘Idle’, you just need to load with a higher priority.