I have tried this but the seat is not changing the animation.

(seat = script.Parent) and (animation = script.animation)

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then

    hit.Parent.Humanoid.Seated:Connect(function()

        local animationtoplay = hit.Parent.Humanoid:LoadAnimation(script.Animation)
        animationtoplay:Play()
        local Player = game.Players:GetPlayerFromCharacter(hit.Parent)

        while wait() do
            if Player.Character.Humanoid.SeatPart == nil then
                animationtoplay:Stop()
            end
            end
        end)
    end
end)