Animations not playing

I am using a script to trigger a sequence of animations. Here is the script:

local function animateFridge(plr, fridge)
	local fridgeAnimator = script.Parent.FridgeCore.AnimationController.Animator
	local openAnimation = script.Parent.FridgeCore.Animations.DoorOpen
	local closeAnimation = script.Parent.FridgeCore.Animations.DoorClose
	
	local openAnimTrack = fridgeAnimator:LoadAnimation(openAnimation)
	
	local character = plr.Character
	if not character or character.Parent then
		character = plr.CharacterAdded:Wait()
	end
	local humanoid = character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")
	local reachForDrink = Instance.new("Animation")
	reachForDrink.AnimationId = "rbxassetid://9154371617"
	local reachForDrinkTrack = animator:LoadAnimation(reachForDrink)
	
	local closeAnimTrack = fridgeAnimator:LoadAnimation(closeAnimation)
	
	openAnimTrack:Play()
	openAnimTrack.Stopped:Wait(0.6)
	reachForDrinkTrack:Play()
	reachForDrinkTrack.Stopped:Wait(0.6)
	closeAnimTrack:Play()
	closeAnimTrack.Stopped:Wait(0.1)
end

The animations aren’t playing at all. They used to work, but they don’t work anymore. I did some debugging, and it cant find the character, but no error is showing up. This is the part with the trouble:

	local character = plr.Character
	if not character or character.Parent then
		character = plr.CharacterAdded:Wait()
	end

How can I fix this? Is there something wrong with the code or is my pc just glitching?

my guess is that the problem is in

if not character or character.Parent

If im not wrong the intended code is

if not character or not character.Parent

. Currently, your code will still run character=plr.CharacterAdded:Wait() because character.Parent is not nil