Issue with Loading Animation from ReplicatedStorage

I need to use an animation for my script. The animation object is in ReplicatedStorage and I declare it in a variable at the Top of my script.

local Animations = ReplicatedStorage:WaitForChild("Animations")
local idleFly = Animations:WaitForChild("fly")

But this doesn’t work on its own. It does work however when I add this simple line just before it:

char:WaitForChild("movement"):WaitForChild("anim")

local Animations = ReplicatedStorage:WaitForChild("Animations")
local idleFly = Animations:WaitForChild("fly")

or also like this:

task.wait(1)
local Animations = ReplicatedStorage:WaitForChild("Animations")
local idleFly = Animations:WaitForChild("fly")

I don’t understand what the script actually needs to wait for. The anim object Parented to movement that is inside the character has no relation to this script whatsoever, so I assume that waiting for that loads the actual thing it needs to load to play the animation. So how would I make the animation load without waiting for the anim object?

What did the error say? For reasons.

There is no error. The state of the animation is playing in both cases, but when I don’t use the wait it just doesn’t appear to be playing on screen.

probably a case cause sometimes the animation will play automatically even when your loading. Causing the animation to leap before you see it

Wait, is there any additional scripts you had except for that?

yea that’s just a small part of the code, but I don’t know what is relevant about it except the declaration of the variables.

what type is the animation? Is it walking, playing automatic or?

it’s a looping flying animation

Can you show the full script?

Sure I could, but is it necessary? It’s a pretty long script and the animation is just played at the beginning.
Here’s a simplified version of the script:

local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator") :: Animator

char:WaitForChild("movement"):WaitForChild("fly")

local Animations = ReplicatedStorage:WaitForChild("Animations")
local idleFly = Animations:WaitForChild("fly")


local function playAnimObj(anim)
	local track = animator:LoadAnimation(anim)
	
    track:Play()
end


local function characterInit()
	hum.AutoRotate = false
	hum:ChangeState(Enum.HumanoidStateType.Physics) --Enum.HumanoidStateType.PlatformStanding

    playAnimObj(idleFly)
end

module.start = function(newConstants, newKeybinds)
	if started then return end

	constants = newConstants or constants
	keyBinds = newKeybinds or keyBinds

	characterInit()

	started = true
end