Need help with LoadAnimation and required Humanoid issues

Hello, my fellas,

I’m trying to make a simple animate script. But it keep giving me error in the output. I hope you guys can help me to find a way to fix this.

ServerScriptService > GameLogic:

local character = player.Character or player.CharacterAdded:Wait()
    local success
    
    repeat
        success = pcall(function()
            character:FindFirstChild("Humanoid")
        end)
        
        if not success then wait(1) end
    until success
    
    local humanoid = character.Humanoid
    local walkTrack = humanoid:LoadAnimation(Animations.Default:WaitForChild("walk"))
    local idleTrack = humanoid:LoadAnimation(Animations.Default:WaitForChild("idle"))
    
    RemoveOldAnimateScript(character)
    Player:PreloadAssets()
    
    humanoid.Running:Connect(function(speed)
        if speed > 0 then
            if walkTrack.IsPlaying == false then
                walkTrack:Play()
                idleTrack:Stop()
            end
        else
            if walkTrack.IsPlaying == true then
                walkTrack:Stop()
                idleTrack:Play()
            end
        end
    end)

Error:

11:51:16.879  LoadAnimation requires the Humanoid object (The_UncleDev.Humanoid) to be a descendant of the game object 
1 Like

game.Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local success

repeat
success = pcall(function()
character:FindFirstChild(“Humanoid”)
end)

if not success then wait(1) end

until success

local humanoid = character.Humanoid
local walkTrack = humanoid:LoadAnimation(Animations.Default:WaitForChild(“walk”))
local idleTrack = humanoid:LoadAnimation(Animations.Default:WaitForChild(“idle”))

RemoveOldAnimateScript(character)
Player:PreloadAssets()

humanoid.Running:Connect(function(speed)
if speed > 0 and walkTrack.IsPlaying == false then
walkTrack:Play()
idleTrack:Stop()
elseif walkTrack.IsPlaying == true then
walkTrack:Stop()
idleTrack:Play()
end
end)
end)
–tried my best