Character animation not playing

  1. What do you want to achieve? Keep it simple and clear!
    I want to make the player play a petting animation for my raise a game when i use a proximity prompt
  2. What is the issue? Include screenshots / videos if possible!
    The character is not playing the animation ONLY FOR THE CHARACTER i tried it on a dummy and the animation plays
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried just playing the animation on the client side, but there is still no use

no errors are showing by the way

Here is the code

local contentProvider = game:GetService("ContentProvider")
local replicatedStorage = game:GetService("ReplicatedStorage")
local danceActivated = replicatedStorage:WaitForChild("RemoteEvents").Petted
local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
local player = game.Players.LocalPlayer
local character  = player.Character or player.CharacterAppearanceLoaded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator") or Instance.new("Animator", humanoid)

local animation = replicatedStorage:WaitForChild("Pet")

danceActivated.OnClientEvent:Connect(function()
	contentProvider:PreloadAsync({animation})
	local animationTrack = humanoid:LoadAnimation(animation)
	animationTrack.Priority = Enum.AnimationPriority.Action
	humanoid.WalkSpeed = 0
	animationTrack:Play()
	Controls:Disable()
	wait(3)
	animationTrack:Stop()
	humanoid.WalkSpeed = 16
	Controls:Enable()
	danceActivated:FireServer()
end)

i dont think it’s the problem but here is the server code

local pathFindingService = game:GetService("PathfindingService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Marker = game.Workspace:WaitForChild("Marker")
local humanoid = Marker:WaitForChild("Humanoid")
local humrp = Marker:WaitForChild("HumanoidRootPart")
humrp:SetNetworkOwner(nil)
local locations = script.Parent
local randomLocations = locations.RandomLocations
local FoodBowl = locations:WaitForChild("Dog Bowl")

local proximityPropmt = humrp:WaitForChild("Pet")
local Petted = ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("Petted")
local lowHunger = ReplicatedStorage:WaitForChild("Bindables").LowHunger

local path = pathFindingService:CreatePath()

local randomLocation = randomLocations:FindFirstChild(math.random(1, 8))
path:ComputeAsync(humrp.Position, randomLocation.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do
	humanoid:MoveTo(waypoint.Position)
	humanoid.MoveToFinished:Wait()	
end
local moveRandomly = true
local stop = false

local hunger
while wait(math.random(1, 3)) do
	proximityPropmt.Triggered:Connect(function(player)
		proximityPropmt.Enabled = false
		stop = true
		Petted:FireClient(player)
		humanoid:MoveTo(humrp.Position)
		local floppaStats = player:WaitForChild("FloppaStats")
		local happinessStat = floppaStats:WaitForChild("Happiness")
		if happinessStat.Value <= 75 then
			happinessStat.Value += 5
			if happinessStat.Value > 75 then
				happinessStat.Value = 75
			end
		end
	end)

	Petted.OnServerEvent:Connect(function()
		stop = false
		proximityPropmt.Enabled = true
	end)
	lowHunger.Event:Connect(function(player)
		hunger = player:WaitForChild("FloppaStats").Hunger
		if FoodBowl.FoodInBowl.Value == true then
			path:ComputeAsync(humrp.Position, Vector3.new(-72.592, 5.6, 57.718))
			local waypoints = path:GetWaypoints()

			for i, waypoint in pairs(waypoints) do
				humanoid:MoveTo(waypoint.Position)
				humanoid.MoveToFinished:Wait()	
			end
			script["Nom Nom Nom"]:Play()
			FoodBowl.FoodInBowl.Value = false
			moveRandomly = false
		end
	end)
	if moveRandomly == true and stop == false then
		local newLocation
		do repeat
				newLocation = randomLocations:FindFirstChild(math.random(1, 8))
				wait()
			until
			newLocation ~= randomLocation
		end
		path:ComputeAsync(humrp.Position, newLocation.Position)
		local waypoints = path:GetWaypoints()

		for i, waypoint in pairs(waypoints) do
			humanoid:MoveTo(waypoint.Position)
			humanoid.MoveToFinished:Wait()	
		end
	elseif moveRandomly == false then
		hunger.Value = 100
		FoodBowl.FoodInBowl.Value = false
		FoodBowl.Food.Transparency = 1
		moveRandomly = true
		wait(math.random(1,3))
	end
end

First question. Did you set the animation priority to action?

yes i did check the animation it is set to action and there are no other animations which has a priority higher

turns out it wasnt the animation it was the player.CharacterAppearanceLoaded:Wait() that was bugging the code