CharacterAdded simply not as I attempt to make animations work on a local script

Hopefully the title gives decent enough context/insight, but if not, I’ll just build on it. A day ago, I had an issue where my animations wouldn’t load for the character once they died, rendering one of my systems useless. I then began to get assistance and fix one of the other issues that happened at the player’s death.

Now, I tried different methods to fix the animation, but the issue always seemed to be that the module script ran far faster than the time of the character’s loading, so I decided to make Player a variable, and do the CharacterAdded:Wait event. Apparently, the character never loads? The script yields and is just not able to do it’s job. Here’s the script here, but I sincerely don’t know what the issue could be.

function AnimationModule.getSingleAnimation(Player, Humanoid, ChosenAnimation)
	print("start relaxin")
	print("we finished waiting")
	local Length = 0

	local KeySequence = KeyProvider:GetKeyframeSequenceAsync(ChosenAnimation.AnimationId)
	--print("Getting the Sequences and loading em")
	local KeyFrame = KeySequence:GetKeyframes()

	for i=1, #KeyFrame do
		local Time = KeyFrame[i].Time
		if Time > Length  then
			Length = Time

	return Humanoid.Animator:LoadAnimation(ChosenAnimation), Length

(If you ask why I made a module isn’t the easy way, the answer is because of length being returned.)

If anyone could help me, I would appreciate it so much, thank you for your time.

Hey, you make a character variable like this:
local character = player.Character or player.CharacterAdded:Wait()
If the Character exists then there is no problems, if it does not it will just wait until it exists.

Doing it like this gives me this error once more.
After I died of course.

Have you tried waiting after the character was added? example: task.wait()

Load Animations using a localscript BTW

Nope, I’ll try that out now. I thought it’d just be bad if the character tried blocking the minute they joined the game but realistically that is probably not happening.

I am already loading the scripts through a local script.

Unfortunately, this didn’t really help. It didn’t seem to do anything.